【发布时间】:2021-06-01 13:52:58
【问题描述】:
如果我把它放在 main.py 中,机器人就会坏掉,没有命令可以工作,但我没有收到错误
@client.event
async def on_message(message):
if client.user.mentioned_in(message):
embed=discord.Embed(description='My prefix here is ?. You can see available commands by typing `?help`', color=0x850000)
await message.channel.send(embed=embed)
如果把它放在 cogs/commands.py 中,on_message 仍然不起作用,但其他命令起作用。但是每次我在不和谐中输入一些东西时都会出现这个错误,即使没有前缀
文件“C:\Users\BUGA\Documents\VSCODE\Python Projects\activity role\cogs\commands.py",第 17 行,在 on_message 中 if client.user.提到_in(message): AttributeError: 'NoneType' object has no attribute '提到_in'
@commands.Cog.listener()
async def on_message(self, message):
if client.user.mentioned_in(message):
embed=discord.Embed(description='My prefix here is ?. You can see available commands by typing ?help', color=0x850000)
await message.channel.send(embed=embed)
【问题讨论】:
标签: python python-3.x discord discord.py