【问题标题】:discord.py Not able to fetch messagesdiscord.py 无法获取消息
【发布时间】:2020-12-02 13:26:44
【问题描述】:

在 discord.py 中,我有一个 @tasks.loop,它每 10 秒运行一次。它通过channel.fetch_message(message-id) 获取消息并将其从hi 编辑为hello。再过 10 秒后,它会将消息更改回 hi。起初它正常工作。但是,当机器人自动重启时,它无法获取消息。我该如何解决这个问题?

【问题讨论】:

    标签: python discord discord.py


    【解决方案1】:

    commands.Bot 没有 fetch_message 属性,只有 abc.Messageable 有。要获取消息,首先需要获取消息发送到的通道,然后获取它。

    # Getting the channel
    channel = bot.get_channel(id_here)
    # if you want a faster way:
    channel = Guild.get_channel(id_here)
    
    # Getting the message
    message = await channel.fetch_message(id_here)
    

    【讨论】:

    • 哦,我确实这样做了,只是我在问题中拼错了。我已编辑问题以纠正我的错误。
    猜你喜欢
    • 1970-01-01
    • 2019-01-12
    • 2019-04-21
    • 2021-01-28
    • 2022-08-05
    • 2020-07-27
    • 2021-07-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多