【发布时间】:2021-02-21 06:42:47
【问题描述】:
今天我对我的代码进行了一些编辑,并试图让它提及服务器中的一个人。当我测试它时,它一直说“TypeError:on_message()缺少1个必需的位置参数:'message'”,我不知道如何解决这个问题。我输入了成员参数,但它仍然不起作用。有谁知道如何解决这个问题?
@client.event
async def on_message(message):
for bad_word in bad_words:
if bad_word in message.content.lower().split(" "):
t = discord.Embed(color=0x039e00, title="Message Removed", description=f":x: {member.mention}, please do not say that here.")
t.set_footer(text="DM TheSuperRobert2498#2498 for bot suggestions.")
await message.channel.send(embed=t)
await message.delete()
return
【问题讨论】:
-
这个错误是从这个函数被调用的时候开始的。这是框架的一部分吗?
client.event是什么?这个函数在哪里被调用? -
该函数在我的
on_ready函数下被调用。 -
好的,我们需要看看它是如何被调用的,以便在诊断这个问题时有任何希望
-
我对 discord.py 还是有点陌生。
-
你自己叫这个吗?如果是这样,您需要将有效消息传递给它。如果不是,那么它似乎是 dpy 的问题,尝试更新它。
标签: python discord.py