Discord机器人on_message事件不会使命令正常运行*

问题描述

曾经浏览过以解决此问题,并实际上尝试将bot.process_commands(message)插入我的代码中,但似乎无济于事。到目前为止,这是代码。只有on_message事件起作用,而命令无效。

import discord
from discord.ext import commands
from discord.ext.commands import CommandNotFound
 
bot = commands.Bot(command_prefix='/')

@bot.event
async def on_message(message):
    if bot.user == message.author:
        return
    message.content = message.content.lower()
    if message.content.startswith('hello') and str(message.channel) != 'images':
        await  message.channel.send('Hi')
    if str(message.channel) == 'images' and message.content != '':
        await message.channel.purge(limit=1)
    
    await bot.process_commands(message)
    

@bot.event
async def on_command_error(ctx,error):
    if isinstance(error,CommandNotFound):
        return
    raise error

@bot.command()
async def Hamdii (ctx,arg):
    await ctx.send(arg)

    
bot.run('token') 

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)