Skip to content

zeropsio/recipe-discord-py

Repository files navigation

Zerops x Discord.py

Discord.py is a powerful module that allows you to interact with the Discord API very easily. This is the most bare-bones example of Discord.py bot running on Zerops with a single ping command running on Python runtime.

discordjs


Deploy to Zerops

You can either click the deploy button to deploy directly on Zerops, or manually copy the import yaml to the import dialog in the Zerops app.


Warning

You'll encounter some runtime errors if DISCORD_TOKEN is not set in the environment variables.


Deploy on Zerops


Recipe features

Latest version of Discord.py running on a load balanced Zerops Python service.


Click here to test Discord bot on every available runtime examples.

Setting up Environment Variables

The steps mentioned here are to be followed after deploying the app and will guide you on how to obtain the two required environment variables to run your Discord.js Bot.

  1. Go to the Discord Application Portal. Create an application if you do not have one already.
  • Go to the Bot section (sidebar), reset the token, and copy the token. This will be used for DISCORD_TOKEN.
  1. Head to your service. If you have full mode, check your sidebar and click on Environment Variables. On that page, you will see an "edit multiple secret variables in .env format" button. Click on it, paste your environment variable in the format shown below, and click on Update Secret Variables. You will then see a button to commit your changes.
# Your Application ID copied from the Bot section.
DISCORD_TOKEN=MTIyNjQ3NDYwNjExODk2NTI3MA.GtSgOF.W7wLWibfGtP2tobLv_DsbFKdjlGmOwzxliTejI 

Production vs. development

This recipe is ready for production as is, and will scale horizontally by adding more containers in case of high traffic surges. If you want to achieve the highest baseline reliability and resiliace, start with at least two containers (add minContainers: 2 in recipe YAML in the bot service section, or change the minimum containers in "Automatic Scaling configuration" section of service detail).


Changes made over the default installation

If you want to modify your existing Discord.js bot to efficiently run on Zerops, there are no changes needed in the codebase on top of the standard installation, just add zerops.yml to your repository.



Need help setting your project up? Join Zerops Discord community.