喵喵時(shí)光機(jī)
2023-03-30 09:48:06
我的機(jī)器人使用 Discord.py 自動(dòng)對(duì)新消息做出反應(yīng),并在 25 顆星后將它們添加到右舷。但是,在運(yùn)行一段時(shí)間后會(huì)出現(xiàn)此錯(cuò)誤:忽略 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貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超8個(gè)贊
如果消息不在配置文件的頻道中,則搜索該頻道時(shí)將找不到它。您可以添加一個(gè)檢查以確保您只與該頻道中的消息進(jìn)行交互:
@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)
添加回答
舉報(bào)
0/150
提交
取消