discord.py命令未执行

kse8i1jr  于 2021-09-08  发布在  Java
关注(0)|答案(1)|浏览(446)

我有多个命令,但它们似乎都不起作用,我把它们都放在一个on_消息事件中,我认为这是一个prolem,所以我把它们都移到了单独的命令中。没有错误。

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')

提前谢谢!

wlzqhblo

wlzqhblo1#

我发现了问题!我要把这个留给其他有同样问题的人。我所做的只是删除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')

相关问题