Skip to content

Instantly share code, notes, and snippets.

View benjamonnguyen's full-sized avatar

Benjamin Nguyen benjamonnguyen

View GitHub Profile
@rluvaton
rluvaton / mongo-error-code.ts
Last active October 23, 2023 06:41
Mongo Error Code #mongo #ts
export enum MongoErrorCode {
OK = 0,
InternalError = 1,
BadValue = 2,
OBSOLETE_DuplicateKey = 3,
NoSuchKey = 4,
GraphContainsCycle = 5,
HostUnreachable = 6,// Categories: NetworkError, RetriableError
HostNotFound = 7,// Categories: NetworkError, RetriableError
UnknownError = 8,
@AileenLumina
AileenLumina / bot.py
Last active May 2, 2022 17:40
discord.py command error handler
async def on_command_error(self, ctx, error):
# if command has local error handler, return
if hasattr(ctx.command, 'on_error'):
return
# get the original exception
error = getattr(error, 'original', error)
if isinstance(error, commands.CommandNotFound):
return
@EvieePy
EvieePy / error_handler.py
Last active January 16, 2024 15:12
Simple Error Handling for ext.commands - discord.py
"""
If you are not using this inside a cog, add the event decorator e.g:
@bot.event
async def on_command_error(ctx, error)
For examples of cogs see:
https://gist.github.com/EvieePy/d78c061a4798ae81be9825468fe146be
For a list of exceptions:
https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#exceptions