mirror of
https://github.com/Floriansylvain/Risitas_BOT.git
synced 2026-08-19 19:53:19 +02:00
🥅 - Catching command errors better than ever
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
from discord.ext import commands
|
||||
|
||||
errors = {commands.MissingRequiredArgument:"A required argument is missing !",
|
||||
commands.TooManyArguments:"You entered too many arguments !",
|
||||
commands.NotOwner:"Only the owner of the bot can use this command... *Where did you get it ?*",
|
||||
commands.BotMissingPermissions:"I'm missing some permissions to execute this command !"}
|
||||
+8
-3
@@ -5,7 +5,7 @@ import discord
|
||||
from discord.ext import commands
|
||||
from miscellaneous import spellchecker
|
||||
from private import TOKEN_BOT
|
||||
|
||||
from errors import errors
|
||||
|
||||
print('Loading started')
|
||||
|
||||
@@ -39,9 +39,14 @@ async def on_command_error(ctx, error):
|
||||
' \'' + str(error) + '\' from ' + str(ctx.author) + ' on ' +
|
||||
(ctx.message.guild.name if ctx.message.guild is not None else 'DMs') + '.')
|
||||
if isinstance(error, commands.CommandNotFound):
|
||||
await ctx.send(spellchecker(str(ctx.message.content)[1:], commandlist))
|
||||
msg = spellchecker(str(ctx.message.content)[1:], commandlist)
|
||||
else:
|
||||
await ctx.send(error)
|
||||
try:
|
||||
msg = errors[type(error)] + "\nPlease follow this pattern :\n``" + \
|
||||
"$" + ctx.command.name + " " + ctx.command.signature + "``"
|
||||
except KeyError:
|
||||
msg = "Something really bad happened (" + str(error) + ")."
|
||||
await ctx.send(msg)
|
||||
|
||||
|
||||
def init():
|
||||
|
||||
Reference in New Issue
Block a user