我最近决定学习如何使用discord.py命令,添加命令时遇到了一些麻烦。无论我将命令更改为什么,当我尝试添加命令时,它总是给出相同的错误:
discord.ext.commands.errors.CommandRegistrationError: The command hellothisisacommand is already an existing command or alias.
问题是,它显然不是,而且无论我将命令更改为什么,它总是给出这个错误。这可能是什么原因造成的?代码如下
import discord
from discord.ext import commands
import os
intents = discord.Intents.default()
intents.members = True
intents.presences = True
client = discord.Client()
bot = commands.Bot(command_prefix = '/')
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@bot.command()
async def hellothisisacommand(ctx):
await print(True)
bot.add_command(hellothisisacommand)
client.run('token')
使用
bot.command()
装饰器本质上等同于(并且排除了使用)bot.add_command
您可以使用
commands.command()
装饰器然后调用bot.add_command
,也可以使用bot.command()
装饰器,但不能同时使用两者Read the docs for more info
以下是文档中的示例:
相关问题 更多 >
编程相关推荐