亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何修復 Discord.py 中的未知消息 (404)

如何修復 Discord.py 中的未知消息 (404)

喵喵時光機 2023-03-30 09:48:06
我的機器人使用 Discord.py 自動對新消息做出反應,并在 25 顆星后將它們添加到右舷。但是,在運行一段時間后會出現此錯誤:忽略 on_raw_reaction_add 中的異常Ignoring exception in on_raw_reaction_addTraceback (most recent call last):  File "C:\Users\timpi\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 312, in _run_event    await coro(*args, **kwargs)  File ".\main.py", line 36, in on_raw_reaction_add    message = await reactchannel.fetch_message(payload.message_id)  File "C:\Users\timpi\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\abc.py", line 935, in fetch_message    data = await self._state.http.get_message(channel.id, id)  File "C:\Users\timpi\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\http.py", line 223, in request    raise NotFound(r, data)discord.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message這是on_raw_reaction_add事件:@bot.eventasync def on_raw_reaction_add(payload):    channel_id = int(config["channelIDMemephone"])    reactchannel = bot.get_channel(channel_id)    message = await reactchannel.fetch_message(payload.message_id)    await star_post_check(message)
查看完整描述

1 回答

?
慕仙森

TA貢獻1827條經驗 獲得超8個贊

如果消息不在配置文件的頻道中,則搜索該頻道時將找不到它。您可以添加一個檢查以確保您只與該頻道中的消息進行交互:


@bot.event

async def on_raw_reaction_add(payload):

    if payload.channel_id == int(config["channelIDMemephone"]):

        reactchannel = bot.get_channel(payload.channel_id)

        message = await reactchannel.fetch_message(payload.message_id)

        await star_post_check(message)


查看完整回答
反對 回復 2023-03-30
  • 1 回答
  • 0 關注
  • 198 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號