Skip to content

Commit 8a514a8

Browse files
committed
docs: update error snippet
1 parent e5c0b34 commit 8a514a8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

docs/src/Guides/03 Creating Commands.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,11 @@ Any error from interactions will trigger `on_command_error`. That includes conte
457457
In this example, we are logging the error and responding to the interaction if not done so yet:
458458
```python
459459
class CustomClient(Client):
460-
async def on_command_error(self, ctx: InteractionContext, error: Exception):
461-
logger.error(error)
462-
if not ctx.responded:
463-
await ctx.send("Something went wrong.")
460+
@listen(disable_default_listeners=True) # tell the dispatcher that this replaces the default listener
461+
async def on_command_error(self, event: CommandError):
462+
logger.error(event.error)
463+
if not event.ctx.responded:
464+
await event.ctx.send("Something went wrong.")
464465

465466
client = CustomErrorClient(...)
466467
```

0 commit comments

Comments
 (0)