discord错误HTTP异常发生

2024-10-16 20:48:42 发布

您现在位置:Python中文网/ 问答频道 /正文

嗨,我好像遇到了一个不和谐的错误。我目前正在编写一个模块,以便在消息发布后将消息固定在特定的通道中。在

模块已经过测试,运行良好,但我遇到了这个错误。在

  File "C:\Users\User\Documents\bot\modules\pinner.py", line 22, in 
on_message
    await self.bot.pin_message(message)


   discord.errors.HTTPException: BAD REQUEST (status code: 400): Cannot execute 
action on a system message

我不知道这个错误在告诉我什么。但我正在使用的代码是:

^{pr2}$

如果有人能帮忙,我将不胜感激。在


Tags: 模块inpymodules消息messageonbot
1条回答
网友
1楼 · 发布于 2024-10-16 20:48:42

发生这种情况是因为您正在尝试锁定系统消息,当有人锁定消息时会显示该消息。在

@User pinned a message to this channel. See all the pins.

您可以通过检查^{}和{a2}进行检查

async def on_message(self, message):
    """Listen for message then pin it"""
    server = message.server
    channelid = '469108626888458241'
    if server and message.channel.id == channelid and message.type != discord.MessageType.pins_add:
        try:
            await self.bot.pin_message(message)
        except discord.Forbidden:
            print("No permissions to do that!")

相关问题 更多 >