Discord Bot Send Embed Message To Another Channel
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=Tru
Solution 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)
Solution 2:
You must use the discord.py rewrite library
First of all, you need to create the command:
@bot.command()asyncdefembed(ctx):
After, you will need to set in which channel the message will be sent:
channel = bot.get_channel(channel id)
Now, you need to create the embed:
embed = discord.Embed(title="Embed test", description="A test for my discord bot", color=0x5bcdee)
embed.add_field(name="Hello!", value="Hello World!", inline=False)
Finally, send the message!
await channel.send(embed=embed)
Full command code:
@bot.command()asyncdefembed(ctx):
channel = bot.get_channel(channel id)
embed = discord.Embed(title="Embed test", description="A test for my discord bot", color=0x5bcdee)
embed.add_field(name="Hello!", value="Hello World!", inline=False)
await channel.send(embed=embed)
Post a Comment for "Discord Bot Send Embed Message To Another Channel"