错误:齿轮中已经存在命令-Discord.py

时间:2020-11-05 01:53:29

标签: python python-3.x discord discord.py

我正在制作一个经济机器人,并在齿轮中添加了许多命令。当命令位于齿轮外时,不会出现错误,但是,无论我将命令命名为什么,我将它们放在齿轮内时,IDE都说该命令已经存在。我可以通过键入以下内容来绕过此点:

bot.remove_command("withdraw")
bot.remove_command("deposit")
bot.remove_command("send")
bot.remove_command("rob")
bot.remove_command("slots")
bot.remove_command("balance")
bot.remove_command("beg")
bot.remove_command("shop")
bot.remove_command("buy")
bot.remove_command("inventory")
bot.add_cog(Metacash(bot))

在班级结束时,我执行的每条命令都会以某种方式起作用。这是必要的方法还是有其他方法?

编辑:这是我的代码的更广泛的示例。

# Beginning of economy system.
class Metacash(commands.Cog):
    @bot.command()
    async def shop(self, ctx):
        # Shop stuff
    
    @bot.command()
    async def buy(self, ctx, item, amount):
        # Buy stuff

    @bot.command()
    async def inventory(self, ctx):
        # Inventory stuff

    @bot.command(help="Withdraw money from your bank to your wallet.")
    async def withdraw(self, ctx, amount=None):
        # Withdraw stuff

    @bot.command(help="Deposit money from your wallet to your bank.")
    async def deposit(self, ctx, amount=None):
        # Deposit stuff

    @bot.command(help="Send money to someone.")
    async def send(self, ctx, member: discord.Member, amount=None):
        # Send stuff

    @bot.command(help="Steal a random amount of MetaCash from someone.")
    async def rob(self, ctx, member: discord.Member):
        # Rob stuff

    @bot.command(help="Slots gambling game.")
    async def slots(self, ctx, amount=None):
        # Slots stuff

    @bot.command(help="Displays current wallet and bank balance.")
    async def balance(self, ctx):
        # Balance stuff

    @bot.command(help="Gives you MetaCash.")
    async def beg(self, ctx):
        # Beg stuff

bot.remove_command("withdraw")
bot.remove_command("deposit")
bot.remove_command("send")
bot.remove_command("rob")
bot.remove_command("slots")
bot.remove_command("balance")
bot.remove_command("beg")
bot.remove_command("shop")
bot.remove_command("buy")
bot.remove_command("inventory")
bot.add_cog(Metacash(bot))
# End of economy system.

0 个答案:

没有答案