0
votes

import discord from discord.ext import commands

class Errors(commands.Cog):

def __init__(self, client):
    self.client = client

@commands.Cog.listener()
async def on_ready(self):
    print ('Cog loaded: errors.py')

    if isinstance(error, commands.MissingRequiredArgument):
        await ctx.send(embed=embedVar)

@commands.Cog.listener()
async def command_not_found(self, ctx, error):
    embedVar = discord.Embed(title='**DEVELOPER**', description='Error occured:\n error.CommandNotFound', color=7419530)
    embedVar.add_field(name='**NOT PARSED**', value='Could not find command.')

    if isinstance(error, commands.CommandNotFound):
        await ctx.send(embed=embedVar)

@commands.Cog.listener()
async def on_permission_error(self, ctx, error):
    embedVar = discord.Embed(title='**DEVELOPER**', description='Error occured:\n error.MissingPermissions', color=7419530)
    embedVar.add_field(name='**NOT PARSED**', value='Missing required permissions.')

    if isinstance(error, commands.MissingPermissions):
        await ctx.send(embed=embedVar)

def setup(client): client.add_cog(Errors(client))

1

1 Answers

0
votes

You don't handle errors like that... Those events do not exist. To handle errors you use the on_command_error event:

@commands.Cog.listener()
async def on_command_error(self, ctx, error):
   if isinstance(error, commands.CommandNotFound):
        # code for `CommandNotFound`
   elif isinstance(error, commands.MissingPermissions):
        ...