Embeds

Making and using embeds with Py-cord

Embeds can make your bot's messages look a lot cooler. It also has other purposes, like fending off imposers - for example, people used to impersonate Dank Memer and trick users into giving them their items. Seeing this, the developers decided to use embeds - since embeds can only be sent by bots and webhooks, no users could impersonate any longer.

So, its clear that embeds are pretty nice. Adding them is simple enough too!

import discord # make sure you install py-cord - read the Home Page
from discord.ext import commands # will be discussed later
import os

bot = commands.Bot(command_prefix='!', case_insensitive=True)

@bot.event
async def on_ready():
    print(f"{bot.user} is ready and online!")

@bot.command()
async def hello(ctx):
    await ctx.send("Hey!")
    
### Embed Command ###

@bot.command()
async def embed(ctx):
    embed = discord.Embed(title="How to make embeds with Py-cord", description="This tutorial will show you how to make embeds in py-cord. Simple enough, so lets get started!", color = discord.Color.from_rbg(255, 255, 255))
    await ctx.send(embed = embed)

bot.run(os.getenv('TOKEN'))

That simple! Lets now add fields, footers and other cool stuff!

@bot.command()
async def embed(ctx):
    embed = discord.Embed(title="How to make embeds with Py-cord", description="This tutorial will show you how to make embeds in py-cord. Simple enough, so lets get started!", color = discord.Color.from_rbg(255, 255, 255))
    embed.add_field(name="With Inline", value="This is what I would look like with inline", inline=True)
    embed.add_field(name="With Inline", value="This is what I would look like with inline", inline=True)
    embed.add_field(name="With Inline", value="This is what I would look like with inline", inline=True)
    embed.add_field(name="Without Inline", value="This is what I would look like without inline", inline=False)
    embed.add_field(name="Without Inline", value="This is what I would look like without inline", inline=False)
    await ctx.send(embed = embed)

You may read the docs for more info - https://pycord.readthedocs.io/en/master/api.html#discord.Embed

Last updated