Heres how to build an interactive Discord bot in under 60 minutes

Categories allow you to control the permissions of multiple channels at the same time using category settings. The loop prevention code here, of course, isn’t strictly necessary; the bot wouldn’t get stuck responding to itself here anyway. Once you’ve created the bot, you should get a message saying, “A wild bot has appeared! Name your bot, and below the Username field, you’ll see a token section, with your token hidden behind a link. The first part of adding a Discord bot involves logging in to the Discord Developer Portal to create a listing for your new bot.

At the top of the code, under the other import statements, add from replit import db. This will allow us to use the Repl.it database. Like before, feel free to add more phrases of your choice to the list.

Getting the Bot Online and Responsive

Game developers and publishers often use Discord as a place to share game goodies with their communities. Automated processes such as blocking unwanted users and responding to user requests are vital to the prosperity and growth of a community. Here, you’re not actually naming the bot, per se—this is the application, which contains the bot. That said, there’s no reason the application and the bot can’t share the same name. Since bots work autonomously without much user input in most cases, they are valuable tools to deploy on any Discord server, personal or otherwise. You can import unique bots that play games for entertainment or those designed to help you manage the user-generated content posted on the server.

  • Host yours on cloud services like Heroku once everything is set up.
  • Customize the server with a profile picture and a name.
  • To keep the Bot running continuously, we will be using another free service called Uptime Robot.
  • Head over to Discord’s bot portal, and create a new application.
  • You’ll now see a security token for your bot on the next page.
  • Don’t get stun-locked by this massive system and let us show you exactly how the Paragon Board works in Diablo 4.

However, this isn’t the bot, just the “Application.” You’ll have to add the bot under the “Bot” tab. Head over to Discord’s bot portal, and create a new application. Lastly, you can now use the “node bot.js” command to run the bot. Create a new folder anywhere on your PC or Mac.

Read Next

Repl.it will continue running a web server even after the tab is closed. But even a web server will only run for up to an hour without any use. The code msg.split(“$new “,1) splits off the message from the “$new” command and stores the message in a variable. In that line of code, take note of the space in “$new “. Here is the updated code for the on_message() function. The update_encouragements() function accepts an encouraging message as an argument.

What is a bot https://www.globalcloudteam.com/how-to-make-a-discord-bot/

Messages that mention everyone on the server, not just the bot. It has a great collection of funny dad jokes we can retrieve for free. Module, we can create, develop, and deploy this Discord bot in less how to make a discord bot than 60 minutes. Include your email address to get a message when this question is answered. The Bot Token is entered correctly in your auth.json file. If you get an error line, you did something wrong.

How to Add Encouraging Messages to the Bot

This simple bot code, along with the code explanation, is taken from the discord.py documentation. We will be adding more features to the bot later. Discord.py revolves around the concept of events. An event is something you listen to and then respond to. For example, when a message happens, you will receive an event about it that you can respond to.

If you’ve tried before and failed, this is very likely the point you gave up. The real work can begin now that you’ve created a bot listing on Discord, got the unique token, and invited it to your server. From this point, you’ll need to set up a few additional parameters, which are used to tell your bot what you want it to do. The bot will stay offline until your code is aligned correctly and synced with the Discord platform. Once you get past this initial setup and coding phase, you can share your new bot with everyone on your server.

How to Add Sad Words to the Bot

Create a text file inside your project root and paste it there. Make sure that you don’t reveal the copied token. You’ve now created a Discord server and are ready to make a bot for controlling certain activities on it. A Discord server or chat room is a space where you manage channels and communications on the platform.

What is a bot https://www.globalcloudteam.com/how-to-make-a-discord-bot/

The first step is to create an application on Discord for your bot to work. The idea here is to generate a token for your bot so that Discord recognizes the code. For this, you’ll need to head over to Discord’s applications page.

How to make a Discord bot

If a Discord message starts with “$new”, then the text after “$new” will be used as a new encouraging message. We are going to use Repl.it’s built-in database to store user-submitted messages. This database is a key-value store that’s built into every repl. The bot is completely functional, but now let’s make it possible to update the bot right from Discord. A user should be able to add more encouraging messages for the bot to use when it detects a sad word.

What is a bot https://www.globalcloudteam.com/how-to-make-a-discord-bot/

To start the web server when main.py is run, add the following line as the second-to-last line, right before the bot runs. Set up Uptime Robot https://www.globalcloudteam.com/ to continuously ping the web server. There is another way to keep your code running even on the free tier but it is a little more complicated.

Finish the setup process and check out your new Discord bot

But, this wouldn’t be much of a tutorial if we stopped at hello world, so let’s go over some of the documentation, so you have a better idea of what’s possible. I suggest you read through as much as you can, as it’s very well documented. The last line logs in with the token from the bot portal. Obviously, the token in the screenshot here is fake. An evergreen writer at XDA Developers serving up reviews, buying guides, deals, and more on smartphones that you care about.

Leave a Comment

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