自动调节Discord.py Bot消息错误?

2024-06-28 11:02:25 发布

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

我正在尝试编写一个自动调节程序,从聊天中过滤掉不好的词,然后删除它们

@automod.command()
@commands.has_permissions(administrator=True)
async def words(ctx):
    client.dispatch(event_name='message_event')
    embed = discord.Embed(colour=0x7bed9f, description='Der Auto-Mod für `words` wurde erfolgreich aktiviert')
    await ctx.send(embed=embed)


@client.event
async def on_message_event(message):
    for word in filtered_words:
        if word in message.content:
            await message.delete()

当我运行代码并输入+automod words时,将发送嵌入消息,说明automod已激活,但我收到以下错误消息:

TypeError:on\u message\u event()缺少1个必需的位置参数:“message”

我现在的问题是,此错误消息的含义是什么?如何修复它?


Tags: inclientevent消息messageasyncondef
1条回答
网友
1楼 · 发布于 2024-06-28 11:02:25

您的message_event需要message参数,因此在分派时需要提供它

bot.dispatch('message_event', ctx.message)

注: bot.dispatch是私有api的一部分,而不是在official documentation中,因为在discord.py(2.0)的下一个主要版本中,它将可能从中删除

相关问题 更多 >