Skip to content

How to create a Discord bot?

Since its launch in 2015, Discord has come a long way from its humble beginnings as a gaming voice chat application. Now the application is packed with features not only for gamers but just about anyone who wants an app where a number of people can communicate.

One of the most useful features of Discord is the insane number of bots available to download and use, which can do anything from sending memes to playing music inside voice channels, among other things.

If the exhaustive bot library at your disposal isn’t enough, you can always code your own bot and that’s exactly what we’re going to do in this article.

Making a Discord bot consists of three major steps and Each part requires its own prerequisites and technical know-how.

  • Making a Bot account
  • Coding and Testing a bot
  • Deploying it on a server

Also read: How to add friends in Discord?

Making a Bot account on Discord

Before we start making our bot, we need to create a bot account and get a token so our bot is authorised and identified on the Discord servers. 

Log-in to your account on the Discord website and follow the steps mentioned below to create abot.

Step 1: Head over to the Applications Page and click on the New Application button.

How to create a Discord bot? | Candid.Technology

Step 2: Enter an application name for your bot.

How to create a Discord bot? | Candid.Technology

Step 3: Click on the Bot option on the left side.

How to create a Discord bot? | Candid.Technology

Step 4: Click on the Add Bot button.

How to create a Discord bot? | Candid.Technology

Step 5: Click on Yes, do it! in the pop-up confirmation box to continue.

How to create a Discord bot? | Candid.Technology

Step 6: Click on the Copy button to copy your token. 

How to create a Discord bot? | Candid.Technology

Also read: How to add friends in Discord?

Coding and testing your bot

Before we jump into actual code, there are a bunch of programming languages that you can choose to code your bot. You can pick from Python, Java, JavaScript and C#.

For the purpose of this article, we’re going forward with Python as it’s the most beginner-friendly language on the list. We’ll be using the wonderful Discord.py library to write our bot’s code

Once you’ve got Python3 and the Discord.py library installed, simply pop open any empty text file on a text editor and start writing your bot’s code.

Here’s an example to get you started. Create a file name example_bot.py and type in the following code. 

import discord

client = discord.Client()

@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))

@client.event
async def on_message(message):

if message.author == client.user:
return

if message.content.startswith('$hello'):
await message.channel.send('Hello!')

client.run('your token here')

Make sure you put your token in the client.run(”) command. 

The code above is for a simple text bot that responds ‘Hello’ to any message sent on the server, which starts with hello.

Now to run the bot, simply run the Python script like any other script you would. 

If you’re on Windows

py -3 example_bot.py

If you’re on Linux

python3 example_bot.py

Also read: How to screen share on Discord?

Adding a bot to your Discord server

If you haven’t already made a test server, now is a good time to do so. Now head back over to the Discord Application Page and follow these steps to get an invite URL for your new bot. 

Step 1: Head over to the OAuth2 tab on your bot page.

How to create a Discord bot? | Candid.Technology

Step 2: Scroll down and tick bot under scopes.

How to create a Discord bot? | Candid.Technology

Step 3: Scroll down more and tick all the permissions your bot needs to function properly.

How to create a Discord bot? | Candid.Technology

Step 4: Once you’re done, the resulting URL can be used to invite your bot to your server of choice.

How to create a Discord bot? | Candid.Technology

There you go. You have your very own Discord bot up and running. 

How to create a Discord bot? | Candid.Technology

Also read: How to add a music bot to Discord?

Hello There!

If you like what you read, please support our publication by sharing it with your friends, family and colleagues. If you're running an Adblocker, we humbly request you to whitelist us.

Share on facebook
Share on whatsapp
Share on twitter
Share on reddit
Share on linkedin
Share on pocket
Share on pinterest
Share on telegram
Share on stumbleupon
Share on digg
Share on tumblr
Share on email
Share on delicious
Share on skype







>