'Extension 'cogs.test' raised an error: CommandRegistrationError: The command test is already an existing command or alias
Can anyone help me fix this error I'm making a discord bot.
import discord
from discord.ext import commands
class Test(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def test(self, ctx):
await ctx.send('test')
def setup(client):
client.add_cog(Test(client))
Solution 1:[1]
Your "setup" function should not be in your class. It cannot be called directly if it is.
import discord
from discord.ext import commands
class Test(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def test(self, ctx):
await ctx.send('test')
def setup(client):
client.add_cog(Test(client))
This should work
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ELH YAS |
