如何通过ID获取消息?

时间:2021-06-01 19:36:26

标签: python discord discord.py

bot=discord.Client()


@bot.event
async def on_message(ctx):
    idbot = 835947059721797702
    if ctx.author.id == idbot:
        print(ctx.content)
        channelsnipe = bot.get_channel(833472112290168842)
        id = await client.get_message(channelsnipe,idbot)

        #await asyncio.sleep(0.2) # Give time for reaction to update on cache
        #reaction = id.reactions[0] # Get first reaction of a message
        #emoji = reaction.emoji
        #await id.add_reaction(emoji)

我正在尝试通过机器人发送给我的 ID 获取消息,在我想对此消息添加反应之后,但我尝试通过 fetch_messageget_message 获取消息,但是没有人工作。我总是有这个错误 module 'discord.client' has no attribute 'get_message'

2 个答案:

答案 0 :(得分:0)

TextChannelDMChannelGroupChannel 对象实现了 Messageable 协议。

实现了 fetch_message 方法。

所以用

message = await channelsnipe.fetch_message(idbot)

答案 1 :(得分:0)

试试

message = await channelsnipe.fetch_message(idbot)