我只是试着制作Discord机器人,我试着把这个命令放到一个类别中,但是,不管我怎么称呼这个命令,这个错误都会出现。 这是我的密码:
import discord,random
from discord.ext import commands
bot = commands.Bot(command_prefix=';')
@bot.event
async def on_ready():
print("bot is ready for stuff")
await bot.change_presence(activity=discord.Game(name=";help"))
class general_stuff(commands.Cog):
"""Stuff that's not important to the bot per say"""
@bot.command()
async def lkibashfjiabfiapbfaipb(self, message):
await message.send("test received.")
bot.add_cog(general_stuff())
bot.run("TOKEN")
这就是我得到的错误:
The command lkibashfjiabfiapbfaipb is already an existing command or alias.
无论我对命令做了多少更改,它都会不断给出相同的错误
你在正确的轨道上。出现错误的原因是,当你启动程序时,它从顶部读取,然后向下运行
@bot.command
将方法添加到bot并加载它。使用Cogs,您可以使用@commands.command()
进行操作。它只将方法转换为命令,但不将其加载您的代码应该如下所示
参考资料:
相关问题 更多 >
编程相关推荐