Discord 事件导致命令无法运行 - Discord.py

Discord event causing commands to not function - Discord.py

我对编程还很陌生,我认为一个好的学习项目将是一个用于个人服务器的 discord 机器人,所有这些都托管在 heroku 上。但我遇到了一个问题,我想寻求帮助。

此事件导致所有其他命令根本无法运行,我不太明白为什么:

import discord
import time
import os
import asyncio
import random

from discord.ext import commands, tasks
from itertools import cycle


client = commands.Bot(command_prefix = '~')

Messages = ['1', '2', '3','4']

@client.command()
async def Load(ctx, extension):
    client.load_extension(f'cogs.{extension}')

@client.command()
async def Unload(ctx, extension):
    client.unload_extension(f'cogs.{extension}')

@client.command()
async def Reload(ctx, extension):
    client.unload_extension(f'cogs.{extension}')
    client.load_extension(f'cogs.{extension}')

for filename in os.listdir('./cogs'):
    if filename.endswith('.py'):
        client.load_extension(f'cogs.{filename[:-3]}')

@client.event
async def on_ready():
    print('Bot is Online')

async def change_status():
    await client.wait_until_ready()
    status = cycle(Messages)

    while not client.is_closed():
        current_status = next(status)
        await client.change_presence(activity=discord.Game(name=current_status))
        await asyncio.sleep(60)
        print ('Status Changed')

@client.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.MissingRequiredArgument):
        await ctx.send('Missing required argument')
    if isinstance(error, commands.CommandNotFound):
        await ctx.send('Command does not exist')
    if isinstance(error, commands.CheckFailure):
        await ctx.send('You do not have permission to use this command')

###################################################################################
@client.event
async def on_message(message):
    member = message.author.id
    if message.author.id == XXXXX:
        if "gif" in message.content:
            responses = ['This part works','']
            await message.channel.send(random.choice(responses))
###################################################################################

@client.command()
async def Commands(ctx):
    await ctx.send('shows commands')

@client.command()
async def Test(ctx):
    await ctx.send('command works')

client.loop.create_task(change_status())
client.run(os.environ['token'])

对于上下文,我有一个朋友喜欢使用 gif 来表达他们对每个人的烦恼的意见,所以目的是在他们这样做时发送消息。我有问题的代码片段在哈希值之间。

提前致谢

添加

await client.process_commands(message)

到 on_message 函数的开头。 on_message 优先,如果您不包含此行,将始终取消命令。