python - Discord 机器人将嵌入消息发送到另一个 channel

标签 python discord discord.py

尽管我可以弄清楚如何将自己的消息发送到另一个 channel ,但我无法弄清楚如何将机器人上的嵌入消息从一个 channel 发送到另一个 channel :

@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)

似乎不起作用,每当我发送它时,我都会收到此<discord.object.Object object at 0x03B66BD0>,然后收到嵌入的消息。

另一方面,当我尝试复制消息而不是嵌入消息时,此有效,以下是复制消息的代码:

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

最佳答案

bot.say() 采用第一个位置参数 message,发送消息并嵌入到命令上下文的 channel (即,命令上下文的 channel )命令消息被机器人接收)。

由于您想将消息发送到不同的 channel ,请改用 bot.send_message():

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

关于python - Discord 机器人将嵌入消息发送到另一个 channel ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50863957/

相关文章:

c# - Discord Bot [C#] 不执行命令

python - Discord Bot 无法离开语音 channel 'NoneType' 对象没有属性 'disconnect'

python - 如何从用户id获取Member对象discord.py

python - GAE 上的 Flask - 连接到 Google API - 无法使用 JSON 文件

python - 在Python中使用正则表达式递归替换某些行

python - 自定义表情符号和动画表情符号不起作用 [discord.py-rewrite]

python - 为多个机器人加载齿轮

Python 正则表达式仅匹配部分括号

python - Pandas :有效地获得所有正增量值

python - 如何修复 discord bot 中的 "SyntaxError: invalid syntax"