最近我一直在学习如何编写一个discord机器人,我遇到了麻烦。我想创建一种方法,允许我将消息从一个通道移动到另一个通道。我创建了一个有效的解决方案,但不是我想要的。理想情况下,我想让机器人几乎做一个reddit转发,在那里它接收准确的消息并将其嵌入。目前我对这个方法的理解是
@client.event
async def on_message(message):
author = message.author
content = message.context
channel = message.channel
if message.content.startswith('!move'):
#code to process the input, nothing special or important to this
for i in fetchedMessages:
embededMessage = discord.Embed()
embededMessage.description = i.context
embededMessage.set_author(name=i.author, icon_url=i.author.avatar_url)
await channelToPostIn.send(embeded=embededMessage)
# delete the old message
i.delete()
现在,这对于文本消息非常有效,但对于图像或例如,如果帖子首先被嵌入,则不适用。如果有人有一个更优雅的解决方案,或者能够在文档中为我指出正确的方向,我将不胜感激。谢谢
@Buster的解决方案工作正常,但用户将图片作为附加到消息的文件上传时除外。为了解决这个问题,我最终设置了嵌入消息的图像,并附加了图像的代理url。我的整个移动命令如下
感谢所有帮助解决这个问题的人
如果您使用} (请查看basic bot),这将容易得多
commands.Bot
扩展名:^{可能的问题:
相关问题 更多 >
编程相关推荐