discord.py 命令未执行

discord.py commands not excecuting

我有多个命令,但 none 似乎有效,我将所有命令都放在一个 on_message 事件中,我认为这是问题所在,所以我将它们全部移动到单独的命令中.没有错误。

import discord
from googleapiclient.discovery import build
from discord.ext import commands
from PIL import Image, ImageFont, ImageDraw
import requests
import json
import textwrap
import random

yt_api_key = ''

youtube = build("youtube", 'v3', developerKey=yt_api_key)
description = '''blank'''

intents = discord.Intents.default()
client = discord.Client()
bot = commands.Bot(command_prefix='$', description=description, intents=intents)


@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))

@bot.command()
async def test(ctx):
    await ctx.send('test')

提前致谢!

我找到问题了!我要把这个留给有同样问题的其他人。 我所做的只是删除 bot 变量并将其放入客户端变量中。 我认为两者是相互重叠的。

import discord
from googleapiclient.discovery import build
from discord.ext import commands
from PIL import Image, ImageFont, ImageDraw
import requests
import json
import textwrap
import random

yt_api_key = ''

youtube = build("youtube", 'v3', developerKey=yt_api_key)
description = '''blank'''

intents = discord.Intents.default()

#-----------changed this---------------
client = commands.Bot(command_prefix='$')
#--------------------------------------


@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))
#-------------and this----------------
@client.command()
#--------------------------------------
async def test(ctx):
    await ctx.send('test')