本文介绍了Discord bot 将嵌入消息发送到另一个频道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我不知道如何将机器人上的嵌入消息从一个渠道发送到另一个渠道,尽管我可以弄清楚如何将自己的消息发送到另一个渠道:

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)

这个似乎不起作用,每当我发送它时,我都会在 0x03B66BD0> 处得到这个 <discord.object.Object 对象,然后是嵌入的消息.

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

推荐答案

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

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

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

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)

这篇关于Discord bot 将嵌入消息发送到另一个频道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 00:20