Python Discord.py on_消息不是@bot.event? 导入日期时间 进口不和 从discord导入消息,ActivityType 从discord.ext导入命令 导入异步 intents=discord.intents().all() bot=commands.bot(命令前缀='.',意图=意图) 帮会=‘迅捷网络’ time=datetime.date.today() 坏字=['bw'、'bw1'、'bw2'、'bw3'] @机器人事件 _ready()上的异步定义: 打印('Wir sind als{1}auf{0}eingeloggt版本:{2}'。格式(guild,bot.user.name,discord.\uuuuuuuuuu版本) 通道=bot.get_通道(id=697572461629407305) wait channel.send('Heute ist der{0}.{1}.{2}'。格式(time.day、time.month、time.year)) #等待bot.channel.send('Beep-Boop-Beep,Roboter-Angriff-wird-gestartet.) bot.loop.create_任务(status_task()) @bot.command() 异步def hello(ctx): 等待ctx.channel.send(f“Hello!{ctx.author.notice}”) @bot.command() 异步定义ping(ctx): 等待ctx.channel.send(轮(bot.latency*1000)) @bot.command() 异步def轮询(ctx、消息、*args): #打印(len(args)+1) 表情符号='1️⃣' pollem=discord.Embed(title='',description=f'{message}') 上下文=[] 反应x=['1️⃣', '2.️⃣', '3.️⃣', '4.️⃣'] 如果len(args)>=2: 对于范围内的r(0,len(args),2): 反应=['1️⃣', '2.️⃣', '3.️⃣', '4.️⃣'] 对于范围内的x(1,len(args),2): append(args[x]) 对于范围内的(0,len(args),2): pollem.add_字段(name='{1}{0}'。格式(args[a],reaction[int(r/2)]),value=context[int(a/2)], 内联=假) ms=wait ctx.channel.send(嵌入=pollem) 其他: 等待ctx.channel.send('检查参数') 异步定义状态_任务(): 异步定义状态_任务(): 尽管如此: 等待bot.change_状态(activity=discord.Game('Hello'),status=discord.status.online) 等待asyncio.sleep(3) 等待bot.change_状态(活动=discord.Game('Moin'),状态=discord.status.online) 等待asyncio.sleep(3) 等待bot.change_presence(activity=discord.activity(type=discord.ActivityType.listing,name=“一首歌”),status=discord.status.online) 等待asyncio.sleep(3) @机器人事件 异步def on_消息(ctx): 如果ctx.author.bot: 返回 对于ctx.content.split(“”)中的单词: 如果单词是坏单词: 等待ctx.delete()

Python Discord.py on_消息不是@bot.event? 导入日期时间 进口不和 从discord导入消息,ActivityType 从discord.ext导入命令 导入异步 intents=discord.intents().all() bot=commands.bot(命令前缀='.',意图=意图) 帮会=‘迅捷网络’ time=datetime.date.today() 坏字=['bw'、'bw1'、'bw2'、'bw3'] @机器人事件 _ready()上的异步定义: 打印('Wir sind als{1}auf{0}eingeloggt版本:{2}'。格式(guild,bot.user.name,discord.\uuuuuuuuuu版本) 通道=bot.get_通道(id=697572461629407305) wait channel.send('Heute ist der{0}.{1}.{2}'。格式(time.day、time.month、time.year)) #等待bot.channel.send('Beep-Boop-Beep,Roboter-Angriff-wird-gestartet.) bot.loop.create_任务(status_task()) @bot.command() 异步def hello(ctx): 等待ctx.channel.send(f“Hello!{ctx.author.notice}”) @bot.command() 异步定义ping(ctx): 等待ctx.channel.send(轮(bot.latency*1000)) @bot.command() 异步def轮询(ctx、消息、*args): #打印(len(args)+1) 表情符号='1️⃣' pollem=discord.Embed(title='',description=f'{message}') 上下文=[] 反应x=['1️⃣', '2.️⃣', '3.️⃣', '4.️⃣'] 如果len(args)>=2: 对于范围内的r(0,len(args),2): 反应=['1️⃣', '2.️⃣', '3.️⃣', '4.️⃣'] 对于范围内的x(1,len(args),2): append(args[x]) 对于范围内的(0,len(args),2): pollem.add_字段(name='{1}{0}'。格式(args[a],reaction[int(r/2)]),value=context[int(a/2)], 内联=假) ms=wait ctx.channel.send(嵌入=pollem) 其他: 等待ctx.channel.send('检查参数') 异步定义状态_任务(): 异步定义状态_任务(): 尽管如此: 等待bot.change_状态(activity=discord.Game('Hello'),status=discord.status.online) 等待asyncio.sleep(3) 等待bot.change_状态(活动=discord.Game('Moin'),状态=discord.status.online) 等待asyncio.sleep(3) 等待bot.change_presence(activity=discord.activity(type=discord.ActivityType.listing,name=“一首歌”),status=discord.status.online) 等待asyncio.sleep(3) @机器人事件 异步def on_消息(ctx): 如果ctx.author.bot: 返回 对于ctx.content.split(“”)中的单词: 如果单词是坏单词: 等待ctx.delete(),python,discord,discord.py,Python,Discord,Discord.py,问题出在最后一件事上。 如果我像这样运行它,ctx.delete()可以工作,但是上面的所有命令都不行。 如果我删除@bot.event,命令会工作,但ctx.delete()不会 我想说的是,我确信这是导致@bot.event的原因,但在on_ready中,我也在使用它,它工作正常。 所以现在我真的看不到代码中有任何问题。当您在消息事件上使用时,它会阻止其他命令工作。要解决这个问题,您需要使用等待bot.process\u命令(消息)。您需要将它添加到消息事件代码的末尾 有关bot.proce

问题出在最后一件事上。 如果我像这样运行它,
ctx.delete()
可以工作,但是上面的所有命令都不行。 如果我删除
@bot.event
,命令会工作,但
ctx.delete()
不会

我想说的是,我确信这是导致
@bot.event
的原因,但在
on_ready
中,我也在使用它,它工作正常。
所以现在我真的看不到代码中有任何问题。

当您在消息事件上使用
时,它会阻止其他命令工作。要解决这个问题,您需要使用
等待bot.process\u命令(消息)
。您需要将它添加到消息事件代码的
末尾


有关
bot.process\u命令
的详细信息,您可以查看。

当您使用
on\u消息
事件时,它将阻止其他命令工作。要解决此问题,您需要使用
等待bot.process\u命令(消息)
。您需要将其添加到
on\u消息
事件代码的末尾


有关
bot.process\u命令的更多信息,您可以查看。

在所有@bot.command()异步定义之前(on\u就绪后)尝试处理它,我真的不知道为什么,但我没有看到任何机器人程序不把它放在那里,这可能是我尝试过的原因。同样的结果,只有删除有效。也许可以在所有@bot.command()async def之前尝试处理它(准备就绪后),我真的不知道为什么,但我没有看到任何机器人不把它放在那里,这可能是一个原因,我尝试了这个。同样的结果,只有删除有效。谢谢你,也谢谢你的更正。-有时英语有点问题。再问一个简短的问题,有没有办法联系你?看起来你是个好朋友我有另一个问题,但我在接下来的70分钟内不能在这里发布。谢谢你,也谢谢你的纠正。-有时英语有点问题。还有一个简短的问题,有没有办法联系你?你似乎对这个问题很在行。我有另一个问题,但我不能发布给她在接下来的70分钟内。。