#Listeners has no attribute error

1 messages · Page 1 of 1 (latest)

ionic relic
#

The Function:

    async def on_command_error(event):
        error = event.error # Access the error 
        if isinstance(error, BadArgument): 
            await event.ctx.send("There was an error with your input. Please make sure all required options are provided and correctly formatted.", ephemeral=True)```

No visible errors or problems, but whenever a BadArgument is raised:
```<Listener event='command_error' callback=<function Listeners.on_command_error at 0x0000027B6F572200>> is listening to command_error event which contains event data. Add an event argument to this listener to receive the event data object.
Ignoring exception in CommandError():
Traceback (most recent call last):
  File "C:\Users\x\AppData\Local\Programs\Python\Python312\Lib\site-packages\interactions\client\client.py", line 630, in _async_wrap
    await _coro()
  File "C:\Users\x\AppData\Local\Programs\Python\Python312\Lib\site-packages\interactions\models\internal\callback.py", line 31, in __call__
    return await self.callback(self._binding, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\x\Documents\UMP Wiki\listeners.py", line 15, in on_command_error
    error = event.error # Access the error
           ^^^^^^^^^^^
AttributeError: 'Listeners' object has no attribute 'error'```

Here are my imports:
import asyncio
import string
import traceback 

from interactions import Extension, listen, Embed, Permissions, ChannelType
from interactions.api.events import ChannelCreate, Component, CommandError, MemberAdd, MemberRemove, MessageCreate, MessageUpdate
from interactions.client.errors import BadArgument
wheat lakeBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

sick lantern
#

Is the listener in a class?

broken pivot
#

Yeah, it definitely is, based on the indentation and name in the traceback

#

Which means you're missing the self argument