|
|
@@ -26,10 +26,13 @@ SOFTWARE. |
|
|
|
|
|
|
|
|
|
|
|
import string |
|
|
|
import discord |
|
|
|
import datetime |
|
|
|
import traceback |
|
|
|
import youtube_dl |
|
|
|
|
|
|
|
import discord |
|
|
|
from discord.ext import commands |
|
|
|
|
|
|
|
import roxbot |
|
|
|
from roxbot import guild_settings |
|
|
|
|
|
|
@@ -53,26 +56,18 @@ class ErrHandle: |
|
|
|
owner = self.bot.get_user(self.bot.owner_id) |
|
|
|
if self.dev: |
|
|
|
raise error |
|
|
|
elif isinstance(error, commands.CommandInvokeError): |
|
|
|
embed = discord.Embed(title='Command Error', colour=roxbot.EmbedColours.dark_red) |
|
|
|
embed.description = str(error) |
|
|
|
embed.add_field(name='Server', value=ctx.guild) |
|
|
|
embed.add_field(name='Channel', value=ctx.channel.mention) |
|
|
|
embed.add_field(name='User', value=ctx.author) |
|
|
|
embed.add_field(name='Message', value=ctx.message.content) |
|
|
|
embed.timestamp = datetime.datetime.utcnow() |
|
|
|
await ctx.send(embed=embed) |
|
|
|
else: |
|
|
|
embed = discord.Embed() |
|
|
|
if isinstance(error, commands.NoPrivateMessage): |
|
|
|
embed = discord.Embed(description="This command cannot be used in private messages.") |
|
|
|
embed.description = "This command cannot be used in private messages." |
|
|
|
elif isinstance(error, commands.DisabledCommand): |
|
|
|
embed = discord.Embed(description="This command is disabled.") |
|
|
|
embed.description = "This command is disabled." |
|
|
|
elif isinstance(error, commands.MissingRequiredArgument): |
|
|
|
embed = discord.Embed(description="Required argument missing. {}".format(error.args[0])) |
|
|
|
embed.description = "Required argument missing. {}".format(error.args[0]) |
|
|
|
elif isinstance(error, commands.BadArgument): |
|
|
|
embed = discord.Embed(description="Bad Argument given. {}".format(error.args[0])) |
|
|
|
embed.description = "Bad Argument given. {}".format(error.args[0]) |
|
|
|
elif isinstance(error, commands.TooManyArguments): |
|
|
|
embed = discord.Embed(description="Too many arguments given.") |
|
|
|
embed.description = "Too many arguments given." |
|
|
|
elif isinstance(error, commands.CommandNotFound): |
|
|
|
cc = guild_settings.get(ctx.guild).custom_commands |
|
|
|
if ctx.invoked_with in cc["1"]: |
|
|
@@ -83,19 +78,36 @@ class ErrHandle: |
|
|
|
# Should avoid punctuation emoticons. Checks all of the command for punctuation in the string. |
|
|
|
embed = None |
|
|
|
else: |
|
|
|
embed = discord.Embed(description="That Command doesn't exist.") |
|
|
|
embed.description = "That Command doesn't exist." |
|
|
|
elif isinstance(error, commands.BotMissingPermissions): |
|
|
|
embed = discord.Embed(description="{}".format(error.args[0].replace("Bot", "roxbot"))) |
|
|
|
embed.description = "{}".format(error.args[0].replace("Bot", "roxbot")) |
|
|
|
elif isinstance(error, commands.MissingPermissions): |
|
|
|
embed = discord.Embed(description="{}".format(error.args[0])) |
|
|
|
embed.description = "{}".format(error.args[0]) |
|
|
|
elif isinstance(error, commands.NotOwner): |
|
|
|
embed = discord.Embed(description="You do not have permission to do this. You are not Roxie!") |
|
|
|
embed.description = "You do not have permission to do this. You are not Roxie!" |
|
|
|
elif isinstance(error, commands.CommandOnCooldown): |
|
|
|
embed = discord.Embed(description="This command is on cooldown, please wait {:.2f} seconds before trying again.".format(error.retry_after)) |
|
|
|
embed.description = "This command is on cooldown, please wait {:.2f} seconds before trying again.".format(error.retry_after) |
|
|
|
elif isinstance(error, commands.CheckFailure): |
|
|
|
embed = discord.Embed(description="You do not have permission to do this. Back off, thot!") |
|
|
|
embed.description = "You do not have permission to do this. Back off, thot!" |
|
|
|
|
|
|
|
elif isinstance(error, commands.CommandInvokeError): |
|
|
|
# YOUTUBE_DL ERROR HANDLING |
|
|
|
if isinstance(error.original, youtube_dl.utils.GeoRestrictedError): |
|
|
|
embed.description = "Video is GeoRestricted. Cannot download." |
|
|
|
elif isinstance(error.original, youtube_dl.utils.DownloadError): |
|
|
|
embed.description = "Video could not be downloaded: {}".format(error.original.exc_info[1]) |
|
|
|
|
|
|
|
# Final catches for errors undocumented. |
|
|
|
else: |
|
|
|
embed = discord.Embed(title='Command Error', colour=roxbot.EmbedColours.dark_red) |
|
|
|
embed.description = str(error) |
|
|
|
embed.add_field(name='Server', value=ctx.guild) |
|
|
|
embed.add_field(name='Channel', value=ctx.channel.mention) |
|
|
|
embed.add_field(name='User', value=ctx.author) |
|
|
|
embed.add_field(name='Message', value=ctx.message.content) |
|
|
|
embed.timestamp = datetime.datetime.utcnow() |
|
|
|
elif isinstance(error, commands.CommandError): |
|
|
|
embed = discord.Embed(description="Command Error. {}".format(error.args[0])) |
|
|
|
embed.description = "Command Error. {}".format(error.args[0]) |
|
|
|
else: |
|
|
|
embed = discord.Embed( |
|
|
|
description="Placeholder embed. If you see this please message {}.".format(str(owner))) |