我的机器人使用 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)
添加回答
举报
0/150
提交
取消