Discord bot send embed message to another channel

戏子无情 提交于 2019-12-24 17:16:15

问题


I cant figure out how to send a embedded message on a bot from one channel to another although I can figure out how to send my own message to another:

@bot.command(pass_context=True)
async def tf1(ctx):
    embed=discord.Embed(title="Test", description="1", color=0x5bcdee)
    embed.set_footer(text="Test2")
    await bot.say(discord.Object(id='456277299189383168'),  embed=embed)

This doesn't seem to work and whenever I send it I get this <discord.object.Object object at 0x03B66BD0> and then the embedded message.

On the other hand this works when I am trying to copy a message and not a embedded message, heres the code for copying my message:

@bot.command(pass_context=True)
async def obisowner(ctx, *, mesg):
    await bot.send_message(discord.Object(id='456277299189383168'), "{}".format(mesg))

回答1:


bot.say() takes a first positional argument message, and send the message and embed to the channel of the command context (ie. the channel of which the command message is received by the bot).

Since you want to send the message to a different channel, use bot.send_message() instead:

await bot.send_message(discord.Object(id='456277299189383168'),  embed=embed)


来源:https://stackoverflow.com/questions/50863957/discord-bot-send-embed-message-to-another-channel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!