Software development

How to Make Your Own Discord Bot

Practical features like commands for administrators and visitors guarantee a pleasant user experience. Whether it’s a multiplayer game or a podcast project, the Mumble voice chat software is becoming increasingly popular. The open-source solution has an appealingly simple structure without scrimping on functions. Another advantage is that anyone can create their own Mumble server. We’ll explain all the steps of the installation, from choosing the right server package to the final configuration.

Creating Discord bot

As previously, feel free to expand the list with more words and phrases. I’m just utilising three things for the time being since users will soon be able to upload other motivational sayings for the bot to utilise. A selection of inspirational messages will now be added for the bot to answer with. The last line launches the bot using the login token when it has been configured. The import of the OS library is done in the second line, however it is just needed to access the.env file’s TOKEN value.

In order to make a discord bot, you must turn your newly created Discord Application into a Bot Application. To do this, head over to the Bot page by clicking on the Bot tab on the left side menu. You will then be bought to the Applications General Information tab.

Installing Bot Dependencies

Making a selection on which to utilise might be challenging. You may wish to join the informal Discord API server in addition to reading the relevant documentation to get a sense of the community that backs each library. The list of people who are connected to this server straight away is on the far right.

Creating Discord bot

Click on Continue and confirm whether or not you want to grant Admin rights of the server to your bot. You can grant or revoke the admin rights later too, so don’t sweat over this option. Now, give a name to your application and hit Create. Make sure to enable all three privileged intents for your bot.


Lastly, you can now use the “node bot.js” command to run the bot. Additionally, we’ll also need a code editor to write and modify the bot functions. We’ll be using Visual Studio Code in this tutorial, although you’re free to use whichever you like. In this article, we’ll tell you how to create a Discord bot and add it to your server.

Creating Discord bot

Finally, the updated list is stored back in the database under the “encouragements” key. The get_quote() function is pretty straightforward. First, it uses the requests module to request data from the API URL. The API returns a random inspirational quote.

Keep reading Real Python by creating a free account or signing in:

Then, you used that channel to .send() a direct message to that new member. Here, you looped through the guild data that Discord has sent client, namely client.guilds. Then, you found the guild with the matching name and printed a formatted string to stdout. Finally, runs your Client using your bot’s token. Now, Discord has generated your application’s authorization URL with the selected scope and permissions.

Creating Discord bot

Using a giant if/else if chain will only hinder your development process in the long run. Finally, select your server and a text channel to serve as an announcements channel. Then click Claim to get your Active Developer Badge. We empower and invest in diverse technology talent to increase representation for all people, and to create higher performing enterprise organizations. Here’s another tutorial with more setup involved if this one was confusing.

Don’t forget to import random at the top of the module, since the on_message() handler utilizes random.choice(). Let’s add on to the previous functionality of your bot by handling the on_message() event. In this example, you used member.create_dm() to create a direct message channel.

Sorry, that was a long winded way of saying nothing. We’re going to make a bot that will listen on Discord and if someone says “Ping” it will reply with “Pong”. They do all kinds of things and I’ve always wondered how they were implemented.

How to create a discord bot python – How to Make a Discord Bot Python

The function returns a string containing the quotation. When a chatter enters the phrase “$inspire,” the bot will additionally deliver a random motivational quotation from an API. The idea of events is central to the software. An event seems to be something you hear and then react to. As instance, you will be given an event about a communication when it occurs that you may reply to. The bot’s programming will be written in Python using the package.

  • A guild (or a server, as it is often called in Discord’s user interface) is a specific group of channels where users congregate to chat.
  • For this, you’ll need to head over to Discord’s applications page.
  • Take care of the final settings for your bot and click “Copy”.
  • This is copying app files into the final directory and moving our working directory there.
  • Head over to BotGhost and click Create a Bot button in the top left corner.

In the event that the present API fails, this method might be readily modified to get quotations from a new API. Let’s now review the functions performed by each line of code in your Discord bot code. Create a file with the extension.env by clicking the “Add file” button. Therefore, if you are working on, only put confidential information in a.env file, such as tokens or keys. Another contribution processor, Patreon, offers a dedicated Discord bot and enables setting up Discord roles as contributor perks. Though it will be simpler, we’re planning to put something similar into practise.

Create the bot on Discord.

Since we’re using the library, make sure it’s downloaded. Make sure you have downloaded the latest version of Python and have your chosen IDE set up and ready. As we now create a new command, we have to register it. This can be done with the .upsert() method from JDA. This method takes as the first parameter the command’s name , and the second parameter is the description of the command.

How to quickly make an OpenSea Sales Bot for Discord without coding

Save these changes by clicking the Save Changes button that will appear. It is very important that you DO NOT enable Requires OAuth2 Code Grant. Enabling this option will mean you will be unable to invite your bot. Make sure to never leak or give another person your Bot’s token, as this will allow them to take full control of your Discord Bot.

This means the commands .quote, .q, and .wind will be recognized in the server and return the randomized quote. Now that we are connected to Discord, we can implement our message handling. As I said earlier, this bot will just respond “Pong” when someone sends “Ping”, so let’s build a pretty simple handler. Now that you have the bot all set up and installed in a server, we can start working on implementing it.

Excited, you may personally reach out to that user and welcome them to your community. You might also tell them about your channels or ask them to introduce themselves. Now that the sad words list has been updated, the on message() function will now examine each message to see whether it contains any of the words on it. The bot will randomly give a message of inspiration whenever a depressing term is discovered. We’ll make improvements to the bot now that it is operational.

The point is that if the bot sends a message, it will be a new event, and then we get a loop. You should only run it again if you add or edit existing commands. Once you fill in these values, run node deploy-commands.js in your project directory to register your commands to a single guild. This will bring you to the Active Developer Badge module on BotGhost. I’m going to be setting up pictures in a very similar manner.

Different functions of your bot will require different intents to be enabled. Click the Reset Token button to how to make a discord bot copy a new Bot TokenOnce again click the Yes, do it! This will reveal your bot’s token and a Copy button.

Let’s take a look at a few things you need to get started. First, you need a Discord account, which you probably have. If not, you can create one for free by heading over to the Discord homepage. You can also download the Discord client and use it on your gaming laptop or even a phone.

Leave a Reply

Your email address will not be published. Required fields are marked *