[英]Command “ping” is not found error discord.py
每当我运行我的 discord python 代码并在 discord 聊天中对其进行测试时,它都会说找不到 ping 命令,即使我在代码中定义了它并且 .run(token) 命令位于底部。
我收到的错误消息是:“忽略命令中的异常无:discord.ext.commands.errors.CommandNotFound:找不到命令“ping””
import discord
from discord.ext import commands
token = "[private token]"
client = commands.Bot(command_prefix="!")
@client.event
async def whenReady():
print("Bot is ready")
@client.command()
async def ping(ctx):
await ctx.send("What it do babyy")
client.run(token)
当我输入 .ping 命令时,机器人应该用短语“what it do babyy”回复,但我得到了错误。
出于显而易见的原因,我也确实用填充符替换了上面代码中的私有令牌。
任何帮助将不胜感激,我是 discord API 的新手,我在这里和那里学习文档和一些论坛。
尝试传递参数pass_context = True
import discord
client = commands.Bot(command_prefix="!")
TOKEN = "token"
@client.event
async def whenReady():
print("Bot is ready")
@client.command(pass_context=True)
async def ping(ctx):
await ctx.send("What it do babyy")
client.run(token)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.