DISCORD PY Bot 不响应命令,没有回溯错误

时间:2021-01-16 22:13:15

标签: python discord discord.py

我感觉 on_message 函数正在影响我的代码,但是我不知道我还能如何为聊天复活节彩蛋定义消息(关于 moe 的消息)。

我的代码:

    import discord
    from discord.ext import commands
    import asyncio
    
    client = commands.Bot(command_prefix="*" , case_insensitive=True ,status=discord.Status.idle, activity=discord.Game("Starting up..."))
    client.remove_command("help")
    
    @client.event
    async def on_ready():
        await client.change_presence(status=discord.Status.do_not_disturb, activity=discord.Game("Preparing Puzzle Event"))
        print("Bot is running.")
    @client.command()
    async def hello(ctx):
      await ctx.send("Hi")
    
    @client.group(invoke_without_command=True)
    async def help(ctx):
        em = discord.Embed(title = "**Command List**" , color = ctx.author.color)
        em.add_field(name = "puzzle1", value = "Starts the first puzzle")
        em.add_field(name = "wisdom", value = "Gives wise wisdom")
        await ctx.send(embed = em)
    @client.command()
    async def wisdom(ctx):
        await ctx.send("Stan Loona")
    @client.command()
    async def clue(ctx):
        await ctx.send("Which puzzle do you want a clue for? \n *1 or *2")
    
    @client.event
    async def on_message(message):
        if message.author == client.user:
            return
        elif message.content.startswith('Moe'):
            await message.channel.send('Is an icon')
        elif message.content.startswith('moe'):
            await message.channel.send('Is an icon')
client.run(My token)

没有回溯错误,甚至没有说机器人在线,根本没有运行。

1 个答案:

答案 0 :(得分:2)

您需要在 client.process_commands 事件末尾添加 on_mesage

@client.event
async def on_message(message):
    # ...

    await client.process_commands(message)

参考: