为什么我不能使用命令前缀?

Why can't I use command prefixes?

每次我尝试使用 commands.Bot(command_prefix=''),程序都会将其读取为错误。例如,使用下面的代码,它带有

Ignoring exception in command None: discord.ext.commands.errors.CommandNotFound: Command "-ping" is not found Ignoring exception in command None: discord.ext.commands.errors.CommandNotFound: Command "ping" is not found

并在我想让机器人说什么之前重复几次(Pong!),在服务器中发送 2 次或更多次...

\我觉得它可能在循环?我不确定,但我让它工作了一次,但我等待的时间越长,每次使用命令它都会发送更多响应? - 我上次尝试时它发送了 16 'Pong's...我能做些什么吗?\

我该如何解决这个问题?

from discord.ext import commands
client = commands.Bot(command_prefix='-')

@client.event
async def on_ready():
    print("Bot is ready for use...")

@client.command()
async def ping(ctx):
    await ctx.send('Pong')

client.run('TOKEN')

问题不是出在你的前缀上,你只是忘记了 client.command 装饰器后面的括号:

from discord.ext import commands
client = commands.Bot(command_prefix='-')

@client.event
async def on_ready():
    print("Bot is ready for use...")

@client.command()
async def ping(ctx):
    await ctx.send('Pong')

client.run('TOKEN')

client.event 装饰器没有任何参数,所以你不需要括号,但是 client.command() 可以有像 name=brief=、[=16 这样的参数=], aliases, ...所以你需要括号。 ^^