在重新启动会话之前获取机器人程序发送的消息



我知道可以使用await ctx.fetch_message(mesId)获取消息对象。尽管如果我发送了一条消息,然后启动机器人程序的会话(重新启动客户端(。脚本无法看到消息。有什么办法可以解决这个问题吗?

此外,值得一提的是,我使用的是discord.Bot型用户,而不是discord.Client

首先没有ctx.fetch_message参考

应该是ctx.channel.fetch_message请记住,您可以使用await bot.get_channel(ID)获取另一个通道,然后获取消息。

你的代码应该是这样的:

# using another channel 
channel = await bot.get_channel(123456)
message = await channel.fetch_message(123456)
# or using ctx
message = await ctx.channel.fetch_message(123456)

文档

最新更新