'this error keeps showing up (discord.py categories error)
I want help because I don't want my help command with no categories code:
class Base64(dccmds.Cog):
@bot.command(pass_context=True)
async def b64encode(ctx, string):
string_b = string.encode("utf-8")
await ctx.send(b64.b64encode(string_b).decode("utf-8"))
@bot.command()
async def b64decode(ctx, string):
string_b = string.encode("utf-8")
await ctx.send(b64.decodebytes(string_b).decode())
bot.add_cog(Base64())
I am getting this error:
I tried everything I could, but still getting the same error
Solution 1:[1]
As the error suggests, you're registering the command twice. First, you add it with bot.command(), and then you add it a second time in the cog, causing the error.
The command should be added only once:
class Base64(commands.Cog):
@commands.command() # this does not add the command, so it gets added later when you add the cog
async def b64encode(self, ctx, string):
string_b = string.encode("utf-8")
await ctx.send(b64.b64encode(string_b).decode("utf-8"))
@commands.command()
async def b64decode(self, ctx, string):
string_b = string.encode("utf-8")
await ctx.send(b64.decodebytes(string_b).decode())
client.add_cog(Base64())
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 | Eric Jin |

