|
|
|
|
|
|
|
|
import traceback |
|
|
import traceback |
|
|
import datetime |
|
|
import datetime |
|
|
import load_config |
|
|
|
|
|
import discord |
|
|
import discord |
|
|
from discord.ext import commands |
|
|
from discord.ext import commands |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ErrHandle(): |
|
|
|
|
|
def __init__(self, Bot): |
|
|
|
|
|
self.bot = Bot |
|
|
|
|
|
self.dev = True # For debugging |
|
|
|
|
|
|
|
|
class ErrHandle: |
|
|
|
|
|
def __init__(self, bot_client): |
|
|
|
|
|
self.bot = bot_client |
|
|
|
|
|
self.dev = False # For debugging |
|
|
|
|
|
self.owner = self.bot.get_user(self.bot.owner_id) |
|
|
|
|
|
print(self.owner) |
|
|
|
|
|
|
|
|
async def on_error(self, event, *args, **kwargs): |
|
|
async def on_error(self, event, *args, **kwargs): |
|
|
if self.dev: |
|
|
if self.dev: |
|
|
traceback.print_exc() |
|
|
traceback.print_exc() |
|
|
else: |
|
|
else: |
|
|
embed = discord.Embed(title=':x: Event Error', colour=0xe74c3c) #Red |
|
|
|
|
|
|
|
|
embed = discord.Embed(title="Roxbot Error", colour=0xe74c3c) #Red |
|
|
embed.add_field(name='Event', value=event) |
|
|
embed.add_field(name='Event', value=event) |
|
|
embed.description = '```py\n{}\n```'.format(traceback.format_exc()) |
|
|
embed.description = '```py\n{}\n```'.format(traceback.format_exc()) |
|
|
embed.timestamp = datetime.datetime.utcnow() |
|
|
embed.timestamp = datetime.datetime.utcnow() |
|
|
try: |
|
|
|
|
|
await self.bot.send_message(self.bot.owner_id, embed=embed) |
|
|
|
|
|
except: |
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await self.owner.send(embed=embed) |
|
|
|
|
|
|
|
|
async def on_command_error(self, ctx, error): |
|
|
async def on_command_error(self, ctx, error): |
|
|
|
|
|
self.owner = self.bot.get_user(self.bot.owner_id) |
|
|
|
|
|
print(self.owner) |
|
|
err_colour = 0x992d22 |
|
|
err_colour = 0x992d22 |
|
|
if isinstance(error, commands.CommandInvokeError): |
|
|
if isinstance(error, commands.CommandInvokeError): |
|
|
if self.dev: |
|
|
if self.dev: |
|
|
|
|
|
|
|
|
else: |
|
|
else: |
|
|
embed = discord.Embed(title=':x: Command Error', colour=err_colour) #Dark Red |
|
|
embed = discord.Embed(title=':x: Command Error', colour=err_colour) #Dark Red |
|
|
embed.add_field(name='Error', value=str(error)) |
|
|
embed.add_field(name='Error', value=str(error)) |
|
|
embed.add_field(name='Server', value=ctx.message.server) |
|
|
|
|
|
embed.add_field(name='Channel', value=ctx.message.channel) |
|
|
|
|
|
embed.add_field(name='User', value=ctx.message.author) |
|
|
|
|
|
|
|
|
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.add_field(name='Message', value=ctx.message.content) |
|
|
embed.timestamp = datetime.datetime.utcnow() |
|
|
embed.timestamp = datetime.datetime.utcnow() |
|
|
try: |
|
|
|
|
|
await self.bot.send_message(await self.bot.get_user_info(load_config.owner), embed=embed) |
|
|
|
|
|
except: |
|
|
|
|
|
raise error |
|
|
|
|
|
|
|
|
await self.owner.send(embed=embed) |
|
|
|
|
|
|
|
|
else: |
|
|
else: |
|
|
if isinstance(error, commands.NoPrivateMessage): |
|
|
if isinstance(error, commands.NoPrivateMessage): |
|
|
embed = discord.Embed(description="This command cannot be used in private messages.", colour=err_colour) |
|
|
|
|
|
await ctx.send(embed=embed) |
|
|
|
|
|
|
|
|
embed = discord.Embed(description="This command cannot be used in private messages.") |
|
|
elif isinstance(error, commands.DisabledCommand): |
|
|
elif isinstance(error, commands.DisabledCommand): |
|
|
embed = discord.Embed(description="This command is disabled.", colour=err_colour) |
|
|
|
|
|
await ctx.send(embed=embed) |
|
|
|
|
|
|
|
|
embed = discord.Embed(description="This command is disabled.") |
|
|
elif isinstance(error, commands.CheckFailure): |
|
|
elif isinstance(error, commands.CheckFailure): |
|
|
embed = discord.Embed(description="You do not have permission to do this. Back off, thot!", colour=err_colour) |
|
|
|
|
|
await ctx.send(embed=embed) |
|
|
|
|
|
|
|
|
embed = discord.Embed(description="You do not have permission to do this. Back off, thot!") |
|
|
elif isinstance(error, commands.MissingRequiredArgument): |
|
|
elif isinstance(error, commands.MissingRequiredArgument): |
|
|
embed = discord.Embed(description="This command cannot be used in private messages.", colour=err_colour) |
|
|
|
|
|
|
|
|
embed = discord.Embed(description="Argument missing.") |
|
|
elif isinstance(error, commands.BadArgument): |
|
|
elif isinstance(error, commands.BadArgument): |
|
|
embed = discord.Embed(description="Invalid Argument given. Please check them.", colour=err_colour) |
|
|
|
|
|
|
|
|
embed = discord.Embed(description="Invalid Argument given. Please check arguments given.") |
|
|
|
|
|
elif isinstance(error, commands.TooManyArguments): |
|
|
|
|
|
embed = discord.Embed(description="Too many arguments given.") |
|
|
|
|
|
elif isinstance(error, commands.CommandNotFound): |
|
|
|
|
|
embed = discord.Embed(description="That Command doesn't exist.") |
|
|
|
|
|
elif isinstance(error, commands.BotMissingPermissions): |
|
|
|
|
|
embed = discord.Embed(description="I am missing the following permissions: {}".format(str(error.missing_perms).strip("[]"))) |
|
|
|
|
|
elif isinstance(error, commands.MissingPermissions): |
|
|
|
|
|
embed = discord.Embed(description="You are missing the following permissions: {}".format(str(error.missing_perms).strip("[]"))) |
|
|
|
|
|
elif isinstance(error, commands.NotOwner): |
|
|
|
|
|
embed = discord.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 {} seconds before trying again.".format(error.retry_after)) |
|
|
else: |
|
|
else: |
|
|
embed = discord.Embed( |
|
|
embed = discord.Embed( |
|
|
description="Placeholder embed. If you see this please message {}.".format(self.bot.get_user(self.bot.owner_id))) |
|
|
|
|
|
await ctx.send(embed=embed) |
|
|
|
|
|
|
|
|
description="Placeholder embed. If you see this please message {}.".format(str(self.owner))) |
|
|
|
|
|
embed.colour = err_colour |
|
|
|
|
|
await ctx.send(embed=embed, delete_after=10) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def setup(Bot): |
|
|
|
|
|
Bot.add_cog(ErrHandle(Bot)) |
|
|
|
|
|
|
|
|
def setup(bot_client): |
|
|
|
|
|
bot_client.add_cog(ErrHandle(bot_client)) |