Skip to content
← Back to Community
How to Make A Discord Bot - Part 4 (Updated 2021)
Profile icon

Hey everyone, we are back with another Discord Bot Tutorial and judging from the number of upvotes I got for Part 3 Compared to Part 1, I decided to show you all today some really cool things.


What is an embed?
It is a special and more cool way to display text, watch this.
The cooler one is called an embed.
Using the help function example we did in the last tutorial, let's turn that boring text into some cool box!!!
Let us look back at what we did in the last tutorial:

@client.command() async def help(ctx): ##Define Embed Here await ctx.send("..........")

Now instead of using ctx.send, we will have to send an embed instead, so do this await ctx.send(embed=embed).
So instead of passing in some text, we are passing in an embed with the name embed.
It's a good practice to give your embed a good name, but if you see it, later on, it gets kinda annoying.
So now we need to define our embed, and here's where it gets a bit CSSsy if you get it.

@client.command() async def help(ctx): embed = discord.Embed( title = 'Help', description = "Try out these commands below", colour = ) #Embed Elements await ctx.send("..........")

We will have to initialize it as an embed object, by using discord.Embed (Capital 'E').
Next, we will have to give it 3 Main Things: Title, Description and Colour
The colour is the line on the left side of the embed.

Do note that the colour of the embed can only be assigned by a discord.Colour Class (Capital 'C'). Most of the basic colours can be used by doing:
Remember to add your brackets at the start and end together with your commas after every line.

Now for the elements.
There are 3 types of elements mostly used: set_author,set_footer,add_field.
The first 2 is quite self-explanatory, so I'll be focusing mainly on add_field.

Author and Footer

embed.set_footer(text = "Made By @Fishball_Noodles. Bot Realeased Since June 01,2020") embed.set_author(name = "Moderation#2520")

As shown in the picture above, a field consists of 2 part the name and value.
The name is just the subtitle of that section, while the value is just the main text. You can add up to as many fields you want, by doing this embed.add_field(name = "Date & Time", value =

As you can see, I used embed.add_field or embed.set_footer for adding elements to the embed. If your variable name was to be something like help_embed, you would have to type help_embed.add_field and trust me on this when you want to send bigger embeds you wouldn't want to do this.
An example of how big my embed is:
Sneak Peek on Moderation 2.0

Role Check

Ok, so you don't want random people who join your server to just clear the chat using the |clear function we talked about in Part 2. Maybe only those with the Moderator Role can do it, sure. So now we are gonna do it is making use of a role check built-in function that will check the user's role before the code is being run.

@client.command() @commands.has_role('Moderators') async def clear(ctx, amount = 10): await

This is very self-explanatory, @commands.has_role(#role_name)
where role_name is the name of the role required in the stringed form.

Lastly, Don't Forget to at the run command to get your bot online and working

Well done guys, if you stuck with me throughout this whole tutorial do let me know in the comments section below. Also if you encountered any problems during the entire process, feel free to ask it in the comment section. I will try to answer all your questions. Hope you found the embed portion especially useful, stay tuned for Part 5 tomorrow, where we will be covering how to accept keyword arguments. Till next time:)

Profile icon
Profile icon
Profile icon
Profile icon
Profile icon
Profile icon
Profile icon
Profile icon
Profile icon
Profile icon
Profile icon

i like your tutorials

Profile icon

Im glad you are inspired to do your own .js series
Also, please go read up Markdown to style your post, cos right now it's mostly text.

Profile icon

I will always have the monopoly on tutorials...

Profile icon

U think im trying to beat you isit.
lol, we specialise in different things

Profile icon

Thanks for sharing tutorials with us. I want to make a discord bot and that is why I am searching for the information online on how to make it. I am glad I have found your post in which you have explained everything. While searching for it online, I have also found site link through which I can hire an essay writers for my assignments. Now, I can easily concentrate on making a discord bot.