我正在尝试编写一个自动调节程序,从聊天中过滤掉不好的词,然后删除它们
@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”
我现在的问题是,此错误消息的含义是什么?如何修复它?
您的
message_event
需要message参数,因此在分派时需要提供它注:
bot.dispatch
是私有api的一部分,而不是在official documentation中,因为在discord.py(2.0)的下一个主要版本中,它将可能从中删除相关问题 更多 >
编程相关推荐