April 14, 2023
is it possible/difficult to make a discord bot in Python?
Have an opinion? Send us proposed edits/additions and we may incorporate them into this article with credit.
Python as a Suitable Language for Discord Bots
"Yes all of what you want to build is possible in pretty much any programing language."
"Python is probably better suited for someone who's just starting out with programming"
"You don’t have to set up another environment on your computer to run Python scripts. You just need the compiler and the Discord.py module. I run mine straight from a .py file on my command line. I’d recommend Python 3.7 or higher as Discord.py no longer supports anything lower."
"If you have experience in JS already, I’d say go with that. Plus, their website is full of documentation if you needed to look something up."
"I started my own bot with Python, then I "translated" it into NodeJS because I felt it will be better. Why? The documentation of DiscordJS is, in my opinion once again, easier to understand than Discord.py. I have been able to add more features to my bot, easier with NodeJS than Python. There is another reason why I chose NodeJS: there is more examples of code, more support available than with Python."
Hosting Discord Bots
Jump to top
Source: "Hosting a Discord bot using AWS" (from reddit, r/aws)
A Discord bot in Python can be hosted on AWS Lambda and DynamoDB.
- Reddit users didn’t completely agree on whether using Lambda would work for all bot functions or whether a virtual machine would be necessary.
- Both options offer a free tier.
- Lambda is typically event-driven, but a cloudwatch scheduled event could be used to trigger it.
- A virtual machine would respond to an event such as a HTTP request or cron.
- Officially endorsed Discord libraries can be used to write the bot.
Hosting options include Fargate or a free-tier EC2 instance for high availability.
- An autoscaling group can also help ensure a server is always running.
- Posting messages on a schedule can be done using EventBridge and SQS.
- For small databases, DynamoDB would be suitable and free.
- Some users suggested a DigitalOcean droplet or even a Raspberry Pi for smaller projects or when AWS is not a good fit.
- AWS can be complicated and pricing is not straightforward, so it might not be the best choice for beginners or small projects.
Source: "im searching for a discord.js vs discord.py com..." (from reddit, r/discordbots)
A comparison was sought between discord.js and discord.py.
- One person stated that they found JS more intuitive and versatile than Python, but offered knowledge and support for either.
- Another person said that Python is easier to write and understand, but less well-documented; this claim was contested by someone else.
- Several people said that JS is easier to read or more intuitive, but opinions varied.
- One person found python easier to learn than JS.
- One user recommended learning both languages to determine which one feels more intuitive.
- Someone said that python is simpler to learn, but less flexible or powerful than JS.
- One user suggested learning discord.js, suggesting that it doesn’t require knowledge of the whole language or library.
- Another user emphasized that it depends on what the user wants to accomplish with the language and library.
- discord.py is still active and safe.
Source: "discord.py vs discord.js vs discord.net" (from reddit, r/CodingHelp)
Reddit post asking for advice on the best library for building a Discord bot
- Asks about differences between python, node.js, and .net languages
- Article linked in post discusses differences between discord.py and discord.js
Concerns raised about discord.js not having a dedicated class for command handling
- Posters unsure if this means limitations or just more difficult to implement
Responses indicate that there is no definitive answer on which is the best library for building a Discord bot
- Suggestion to start with language the poster is already familiar with
Source: "[Discord Bot] Choosing the correct programming ..." (from reddit, r/Discord_Bots)
- Python offers “discord.py” while the main package for NodeJS is “discord.js.”
- A reddit user claims that the documentation for “discord.js” is easier to understand than for “discord.py.”
- NodeJS may offer more support and examples of code.
- Several people commented that NodeJS is as stable as Python.
- One user recommends choosing a language according to one’s own preferences.
- One user suggests choosing the language you are most familiar with.
- None of the respondents suggest that creating a Discord bot in Python is difficult.
Source: "[Python][Nextcord] Seeking help with interactio..." (from reddit, r/Discord_Bots)
Relevant info on making a Discord bot in Python:
Relevant info on difficulty of making a Discord bot in Python:
Relevant info on using interaction checks in a Discord bot:
To ensure that the code is only moving forward if the person who clicked the button is the command user, use an if statement that checks the
- A useful tutorial on button interactions in Discord bots can be found at the provided YouTube link.
- To ensure that the code is only moving forward if the person who clicked the button is the command user, use an if statement that checks the
💭 Looking into
What resources are available to help me learn more about Discord bot development?
💭 Looking into
What is the best way to debug errors in a Discord bot?
💭 Looking into
What features does Next Cord offer compared to other Discord bot development tools?
💭 Looking into
What are the advantages and disadvantages of using Discord.js?
💭 Looking into
What are the minimum requirements for using Discord.py?
- Another person mentions that while Discord.js is a popular library, it makes previous code useless on every major update and it is not recommended.
A third person points out that Discord.py is equally organized and consistent and was actually discontinued then recontinued because other libraries were inconsistent and not good alternatives.
- Yet another user links a Gist where it is announced that Discord.py is being recontinued because Discord is deprecating API versions 6 and 7 which the latest version of Discord.py (v.1.7.3) uses and there’s no good alternative to it.
Another user personally enjoys using the Python library way more than Discord.js:
- Type contracts make a huge difference for them and cogs help them organize their code in a much better way.
- They found that making a help command was way more intuitive and easy with Discord.py because the docstrings can be used as the help message, meaning your help command is also written as you document your code.
- A user points out that the choice ultimately depends on the language that you want to work with and what you are comfortable with.
- Another person recommends starting with smaller projects if you want to make a bot using Python and suggests to stick to what you know for a moment while learning the basics of Python if you don’t have any.
- Lastly, someone suggests using .NET.
Source: "How to create a Discord bot with Python: Part 1..." (from reddit, r/Python)
- URL: https://youtu.be/XUCITCMSpIk
- Two year old tutorial video on creating a Discord bot with Python.
Reddit comments on the video post:
- Python is good for getting into Discord bot basics as discord.py is straightforward.
- The basics are reasonably simple and easy to learn.
- The video series is for beginners.
- Recommended for people trying to learn more.
- Creating Discord bots is a fun project.
- Discord.py library is good for getting into bot creation.
- Raspberry Pi is suggested to run bots.
- OOP design is essential to learn before creating a bot.
- Functional programming is suggested to new programmers.
- Heroku, GCP, AWS, and Azure are suggested for hosting bots.
- Unhandled exceptions can cause bots to go offline.
- There’s plenty of competition in tutorial videos on creating Discord bots.
Source: "How hard is it to create a bot?" (from reddit, r/Discord_Bots)
According to a Reddit user, it is possible to create a discord bot that rolls numbers, sends pictures, and tracks points.
- The user suggests that any programming language can accomplish this, but only the user’s skills and creativity would limit them.
- Python is better suited for someone who is just starting programming.
- This user posted the link to the GitHub repository that holds all the code for their bot and includes directions for how they accomplished this.
- The functionalities that you can create are endless, so it is important to use all available resources to learn how to add those functionalities.
A different Reddit user added that no need of setting up another environment to run Python scripts; only a compiler and the Discord.py module are required.
- The user recommends using Python 3.7 or higher as Discord.py no longer supports anything lower.
Source: "Is making your own bot hard?" (from reddit, r/discordapp)
Making a Discord bot would depend on the complexity of the bot; some tasks are easier with programming experience, and some aren’t.
- Programming experience would be recommended.
Special programs must be downloaded to program the bot, depending on the language used.
- For Python, a Python interpreter is necessary.
Personal preference is discord.js, which has a user-friendly website and community.
- An online guide for personal use: https://anidiotsguide.gitbooks.io/discord-js-bot-guide/
Source: "Python discord.py Bot - Setup" (from reddit, r/Discord_Bots)
- The webpage provides a tutorial on making a discord bot with Python.
- Some users suggest migrating to other modules like Next Cord or Pycord due to limitations in Discord.py.
- A user mentions that Discord.py is back in active development and has implemented most of the new features.
- A discussion on the use of timeout function in Discord.py takes place.
- Overall, the webpage provides helpful information on creating a Discord bot with Python, and mentions the limitations and alternative options available.
💭 Looking into
What is the best way to make a Discord bot in Python?