aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/content/resources
diff options
context:
space:
mode:
authorGravatar Exenifix <[email protected]>2022-12-04 13:19:08 +0300
committerGravatar GitHub <[email protected]>2022-12-04 13:19:08 +0300
commit92a9669ee06ea6341082aaceb6f2d2ad5585d007 (patch)
treef45b37e10e0e59822a795d5a9a2e0bc403501a23 /pydis_site/apps/content/resources
parentUpdate pydis_site/apps/content/resources/guides/python-guides/docker-hosting-... (diff)
parentRename vps_services.md to vps-services.md (#808) (diff)
Merge branch 'python-discord:main' into main
Diffstat (limited to 'pydis_site/apps/content/resources')
-rw-r--r--pydis_site/apps/content/resources/guides/pydis-guides/asking-good-questions.md2
-rw-r--r--pydis_site/apps/content/resources/guides/python-guides/fix-ssl-certificate.md23
-rw-r--r--pydis_site/apps/content/resources/guides/python-guides/keeping-tokens-safe.md29
-rw-r--r--pydis_site/apps/content/resources/guides/python-guides/proper-error-handling.md70
-rw-r--r--pydis_site/apps/content/resources/guides/python-guides/vps-services.md41
-rw-r--r--pydis_site/apps/content/resources/guides/python-guides/vps_services.md58
-rw-r--r--pydis_site/apps/content/resources/tags/_info.yml3
7 files changed, 160 insertions, 66 deletions
diff --git a/pydis_site/apps/content/resources/guides/pydis-guides/asking-good-questions.md b/pydis_site/apps/content/resources/guides/pydis-guides/asking-good-questions.md
index 971989a9..b08ba7c6 100644
--- a/pydis_site/apps/content/resources/guides/pydis-guides/asking-good-questions.md
+++ b/pydis_site/apps/content/resources/guides/pydis-guides/asking-good-questions.md
@@ -26,7 +26,7 @@ If none of the above steps help you or you're not sure how to do some of the abo
# A Good Question
-When you're ready to ask a question, there's a few things you should have to hand before forming a query.
+When you're ready to ask a question, there are a few things you should have to hand before forming a query.
* A code example that illustrates your problem
* If possible, make this a minimal example rather than an entire application
diff --git a/pydis_site/apps/content/resources/guides/python-guides/fix-ssl-certificate.md b/pydis_site/apps/content/resources/guides/python-guides/fix-ssl-certificate.md
new file mode 100644
index 00000000..096e3a90
--- /dev/null
+++ b/pydis_site/apps/content/resources/guides/python-guides/fix-ssl-certificate.md
@@ -0,0 +1,23 @@
+---
+title: Fixing an SSL Certificate Verification Error
+description: A guide on fixing verification of an SSL certificate.
+---
+
+We're fixing the error Python specifies as [ssl.SSLCertVerificationError](https://docs.python.org/3/library/ssl.html#ssl.SSLCertVerificationError).
+
+# How to fix SSL Certificate issue on Windows
+
+Firstly, try updating your OS, wouldn't hurt to try.
+
+Now, if you're still having an issue, you would need to download the certificate for the SSL.
+
+The SSL Certificate, Sectigo (cert vendor) provides a download link of an [SSL certificate](https://crt.sh/?id=2835394). You should find it in the bottom left corner, shown below:
+
+A picture where to find the certificate in the website is:
+![location of certificate](/static/images/content/fix-ssl-certificate/pem.png)
+
+You have to setup the certificate yourself. To do that you can just click on it, or if that doesn't work, refer to [this link](https://portal.threatpulse.com/docs/sol/Solutions/ManagePolicy/SSL/ssl_chrome_cert_ta.htm)
+
+# How to fix SSL Certificate issue on Mac
+
+Navigate to your `Applications/Python 3.x/` folder and double-click the `Install Certificates.command` to fix this.
diff --git a/pydis_site/apps/content/resources/guides/python-guides/keeping-tokens-safe.md b/pydis_site/apps/content/resources/guides/python-guides/keeping-tokens-safe.md
new file mode 100644
index 00000000..9d523b4b
--- /dev/null
+++ b/pydis_site/apps/content/resources/guides/python-guides/keeping-tokens-safe.md
@@ -0,0 +1,29 @@
+---
+title: Keeping Discord Bot Tokens Safe
+description: How to keep your bot tokens safe and safety measures you can take.
+---
+It's **very** important to keep a bot token safe,
+primarily because anyone who has the bot token can do whatever they want with the bot --
+such as destroying servers your bot has been added to and getting your bot banned from the API.
+
+# How to Avoid Leaking your Token
+To help prevent leaking your token,
+you should ensure that you don't upload it to an open source program/website,
+such as replit and github, as they show your code publicly.
+The best practice for storing tokens is generally utilising .env files
+([click here](https://vcokltfre.dev/tips/tokens/.) for more information on storing tokens safely).
+
+# What should I do if my token does get leaked?
+
+If for whatever reason your token gets leaked, you should immediately follow these steps:
+- Go to the list of [Discord Bot Applications](https://discord.com/developers/applications) you have and select the bot application that had the token leaked.
+- Select the Bot (1) tab on the left-hand side, next to a small image of a puzzle piece. After doing so you should see a small section named TOKEN (under your bot USERNAME and next to his avatar image)
+- Press the Regenerate button to regenerate your bot token and invalidate the old one.
+
+![Steps to Take to Reset your Discord Bot](/static/images/content/regenerating_token.jpg)
+
+Following these steps will create a new token for your bot, making it secure again and terminating any connections from the leaked token.
+The old token will stop working though, so make sure to replace the old token with the new one in your code if you haven't already.
+
+# Summary
+Make sure you keep your token secure by storing it safely, not sending it to anyone you don't trust, and regenerating your token if it does get leaked.
diff --git a/pydis_site/apps/content/resources/guides/python-guides/proper-error-handling.md b/pydis_site/apps/content/resources/guides/python-guides/proper-error-handling.md
new file mode 100644
index 00000000..74b0f59b
--- /dev/null
+++ b/pydis_site/apps/content/resources/guides/python-guides/proper-error-handling.md
@@ -0,0 +1,70 @@
+---
+title: Proper error handling in discord.py
+description: Are you not getting any errors? This might be why!
+---
+If you're not recieving any errors in your console, even though you know you should be, try this:
+
+# With bot subclass:
+```py
+import discord
+from discord.ext import commands
+
+import traceback
+import sys
+
+class MyBot(commands.Bot):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+
+ async def on_command_error(self, ctx: commands.Context, error):
+ # Handle your errors here
+ if isinstance(error, commands.MemberNotFound):
+ await ctx.send("I could not find member '{error.argument}'. Please try again")
+
+ elif isinstance(error, commands.MissingRequiredArgument):
+ await ctx.send(f"'{error.param.name}' is a required argument.")
+ else:
+ # All unhandled errors will print their original traceback
+ print(f'Ignoring exception in command {ctx.command}:', file=sys.stderr)
+ traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr)
+
+bot = MyBot(command_prefix="!", intents=discord.Intents.default())
+
+bot.run("token")
+```
+
+# Without bot subclass
+```py
+import discord
+from discord.ext import commands
+
+import traceback
+import sys
+
+async def on_command_error(self, ctx: commands.Context, error):
+ # Handle your errors here
+ if isinstance(error, commands.MemberNotFound):
+ await ctx.send("I could not find member '{error.argument}'. Please try again")
+
+ elif isinstance(error, commands.MissingRequiredArgument):
+ await ctx.send(f"'{error.param.name}' is a required argument.")
+ else:
+ # All unhandled errors will print their original traceback
+ print(f'Ignoring exception in command {ctx.command}:', file=sys.stderr)
+ traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr)
+
+bot = commands.Bot(command_prefix="!", intents=discord.Intents.default())
+bot.on_command_error = on_command_error
+
+bot.run("token")
+```
+
+
+Make sure to import `traceback` and `sys`!
+
+-------------------------------------------------------------------------------------------------------------
+
+Useful Links:
+- [FAQ](https://discordpy.readthedocs.io/en/latest/faq.html)
+- [Simple Error Handling](https://gist.github.com/EvieePy/7822af90858ef65012ea500bcecf1612)
diff --git a/pydis_site/apps/content/resources/guides/python-guides/vps-services.md b/pydis_site/apps/content/resources/guides/python-guides/vps-services.md
index 0acd3e55..710fd914 100644
--- a/pydis_site/apps/content/resources/guides/python-guides/vps-services.md
+++ b/pydis_site/apps/content/resources/guides/python-guides/vps-services.md
@@ -1,9 +1,12 @@
---
-title: VPS Services
-description: On different VPS services
+title: VPS and Free Hosting Service for Discord bots
+description: This article lists recommended VPS services and covers the disasdvantages of utilising a free hosting service to run a discord bot.
+toc: 2
---
-If you need to run your bot 24/7 (with no downtime), you should consider using a virtual private server (VPS). This is a list of VPS services that are sufficient for running Discord bots.
+## Recommended VPS services
+
+If you need to run your bot 24/7 (with no downtime), you should consider using a virtual private server (VPS). Here is a list of VPS services that are sufficient for running Discord bots.
* Europe
* [netcup](https://www.netcup.eu/)
@@ -25,7 +28,31 @@ If you need to run your bot 24/7 (with no downtime), you should consider using a
* [OVHcloud](https://www.ovhcloud.com/)
* [Vultr](https://www.vultr.com/)
----
-# Free hosts
-There are no reliable free options for VPS hosting. If you would rather not pay for a hosting service, you can consider self-hosting.
-Any modern hardware should be sufficient for running a bot. An old computer with a few GB of ram could be suitable, or a Raspberry Pi.
+
+## Why not to use free hosting services for bots?
+While these may seem like nice and free services, it has a lot more caveats than you may think. For example, the drawbacks of using common free hosting services to host a discord bot are discussed below.
+
+### Replit
+
+- The machines are super underpowered, resulting in your bot lagging a lot as it gets bigger.
+
+- You need to run a webserver alongside your bot to prevent it from being shut off. This uses extra machine power.
+
+- Repl.it uses an ephemeral file system. This means any file you saved through your bot will be overwritten when you next launch.
+
+- They use a shared IP for everything running on the service.
+This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. Including you.
+
+### Heroku
+- Bots are not what the platform is designed for. Heroku is designed to provide web servers (like Django, Flask, etc). This is why they give you a domain name and open a port on their local emulator.
+
+- Heroku's environment is heavily containerized, making it significantly underpowered for a standard use case.
+
+- Heroku's environment is volatile. In order to handle the insane amount of users trying to use it for their own applications, Heroku will dispose your environment every time your application dies unless you pay.
+
+- Heroku has minimal system dependency control. If any of your Python requirements need C bindings (such as PyNaCl
+ binding to libsodium, or lxml binding to libxml), they are unlikely to function properly, if at all, in a native
+ environment. As such, you often need to resort to adding third-party buildpacks to facilitate otherwise normal
+ CPython extension functionality. (This is the reason why voice doesn't work natively on heroku)
+
+- Heroku only offers a limited amount of time on their free programme for your applications. If you exceed this limit, which you probably will, they'll shut down your application until your free credit resets.
diff --git a/pydis_site/apps/content/resources/guides/python-guides/vps_services.md b/pydis_site/apps/content/resources/guides/python-guides/vps_services.md
deleted file mode 100644
index 710fd914..00000000
--- a/pydis_site/apps/content/resources/guides/python-guides/vps_services.md
+++ /dev/null
@@ -1,58 +0,0 @@
----
-title: VPS and Free Hosting Service for Discord bots
-description: This article lists recommended VPS services and covers the disasdvantages of utilising a free hosting service to run a discord bot.
-toc: 2
----
-
-## Recommended VPS services
-
-If you need to run your bot 24/7 (with no downtime), you should consider using a virtual private server (VPS). Here is a list of VPS services that are sufficient for running Discord bots.
-
-* Europe
- * [netcup](https://www.netcup.eu/)
- * Germany & Austria data centres.
- * Great affiliate program.
- * [Yandex Cloud](https://cloud.yandex.ru/)
- * Vladimir, Ryazan, and Moscow region data centres.
- * [Scaleway](https://www.scaleway.com/)
- * France data centre.
- * [Time 4 VPS](https://www.time4vps.eu/)
- * Lithuania data centre.
-* US
- * [GalaxyGate](https://galaxygate.net/)
- * New York data centre.
- * Great affiliate program.
-* Global
- * [Linode](https://www.linode.com/)
- * [Digital Ocean](https://www.digitalocean.com/)
- * [OVHcloud](https://www.ovhcloud.com/)
- * [Vultr](https://www.vultr.com/)
-
-
-## Why not to use free hosting services for bots?
-While these may seem like nice and free services, it has a lot more caveats than you may think. For example, the drawbacks of using common free hosting services to host a discord bot are discussed below.
-
-### Replit
-
-- The machines are super underpowered, resulting in your bot lagging a lot as it gets bigger.
-
-- You need to run a webserver alongside your bot to prevent it from being shut off. This uses extra machine power.
-
-- Repl.it uses an ephemeral file system. This means any file you saved through your bot will be overwritten when you next launch.
-
-- They use a shared IP for everything running on the service.
-This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. Including you.
-
-### Heroku
-- Bots are not what the platform is designed for. Heroku is designed to provide web servers (like Django, Flask, etc). This is why they give you a domain name and open a port on their local emulator.
-
-- Heroku's environment is heavily containerized, making it significantly underpowered for a standard use case.
-
-- Heroku's environment is volatile. In order to handle the insane amount of users trying to use it for their own applications, Heroku will dispose your environment every time your application dies unless you pay.
-
-- Heroku has minimal system dependency control. If any of your Python requirements need C bindings (such as PyNaCl
- binding to libsodium, or lxml binding to libxml), they are unlikely to function properly, if at all, in a native
- environment. As such, you often need to resort to adding third-party buildpacks to facilitate otherwise normal
- CPython extension functionality. (This is the reason why voice doesn't work natively on heroku)
-
-- Heroku only offers a limited amount of time on their free programme for your applications. If you exceed this limit, which you probably will, they'll shut down your application until your free credit resets.
diff --git a/pydis_site/apps/content/resources/tags/_info.yml b/pydis_site/apps/content/resources/tags/_info.yml
new file mode 100644
index 00000000..054125ec
--- /dev/null
+++ b/pydis_site/apps/content/resources/tags/_info.yml
@@ -0,0 +1,3 @@
+title: Tags
+description: Useful snippets that are often used in the server.
+icon: fas fa-tags