I was using Discord.py, but when I tried to have the bot display embed using the code below, it didn't show up.Where should I correct it?

Asked 2 years ago, Updated 2 years ago, 102 views

I was using Discord.py, but when I tried to have the bot display embed using the code below, it didn't show up.Where should I correct it?

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('$test'):
        wait message.channel.send(embed))
embedded=embedobj
embedded=discord.Embed(title="Bot Help List", colour=discord.Colour(0x112f43), url="https://discordapp.com", description="``Prefix:$``", timestamp=datetime.utcfromtimestamp(1551172370))

embedded.set_image()
embedded.set_thumbnail(url="http://3.bp.blogspot.com/-k74QBLjNuyg/TtiCcfDf2pI/AAAAAAAAAGw/coMwMiItguo/s1600/Mameshiba-Edamame-Wallpaper.jpg")
embedded.set_author(name="eDaMAme#1597", url="https://discordapp.com", icon_url="https://bit.ly/2SsIBiC")
embedded.set_footer(text="footer text", icon_url="https://cdn.discordapp.com/embed/avatars/0.png")

embedded.add_field(name="$hello", value="Say hello")
embedded.add_field(name="$weather", value="weather information")
embedded.add_field(name="$zisin", value="earthquake information")
embedded.add_field(name="$happy,$sad,$angry", value="emoji display", inline=True)
embedded.add_field(name="Various others", value="Will be added", inline=True)

wait bot.say(embed=embed)

client.run('token')

python discord

2022-09-30 21:38

3 Answers

It's the async version.There's a huge update coming up soon, so you'd better switch to the new version of Rewrite as soon as possible.

Let's get down to business, but I'm concerned about embed=embedobj.Embedobj seems to be undefined.I don't think you need this line.
Also, embed.set_image() requires arguments.If you don't want to add an image, you don't need that line.


2022-09-30 21:38

There are no errors, right?

 if message.author==client.user:

Isn't this the problem?

 if message.author==client.user:
    return

This means that the message is repelled by the user.
If you want to hear what BOT said,

 if message.author.bot:
    return

Let's rewrite it like this.


2022-09-30 21:38

import discord

embedded=discord.Embed(title="Bot Help List", colour=discord.Colour(0x112f43), url="https://discordapp.com", description="``Prefix:$``", timestamp=datetime.utcfromtimestamp(1551172370))
embedded.set_thumbnail(url="http://3.bp.blogspot.com/-k74QBLjNuyg/TtiCcfDf2pI/AAAAAAAAAGw/coMwMiItguo/s1600/Mameshiba-Edamame-Wallpaper.jpg")
embedded.set_author(name="eDaMAme#1597", url="https://discordapp.com", icon_url="https://bit.ly/2SsIBiC")
embedded.set_footer(text="footer text", icon_url="https://cdn.discordapp.com/embed/avatars/0.png")
embedded.add_field(name="$hello", value="Say hello")
embedded.add_field(name="$weather", value="weather information")
embedded.add_field(name="$zisin", value="earthquake information")
embedded.add_field(name="$happy,$sad,$angry", value="emoji display", inline=True)
embedded.add_field(name="Various others", value="Will be added", inline=True)

client=discord.Client(ints=discord.Intents.all())

@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('$test'):
        wait message.channel.send(embed=embed)

client.run('token')


2022-09-30 21:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.