Now that we have covered how to make a basic discord bot, we can expand it by adding the ability to embed messages in a beautiful format.
Registering the command.
We all know we can register a new command by:
@bot.command()
async def showEmbed(ctx):
Storing the required variables beforehand.
We will create most of the variable required beforehand.
#This will be our title
title = 'A Basic Embed'
# Our description
description = 'Our Description'
# We will use the hex value directly for the color of the embed.
embed_color = 0xA03B62
Actually creating the embed.
Now we can create a discord embed fairly easily.
# Creating a Discord Embed
embed = discord.Embed(
title = title,
description = description,
color = embed_color
)
Adding fields to the embed.
We can now add various fields to the embed.
# Adding the various fields
embed.add_field(name='F1', value='Field One')
embed.add_field(name='F2', value='Field Two')
embed.add_field(name='F3', value='Field Three')
Sending the embed as a message.
Now, we only need to send the embed as a reply.
# Sending the embed
await ctx.channel.send(content=None, embed=embed)
Final Result
