Browse Source

Removing obsolete command that is convered by the library. Again.

tags/v1.4.0
roxie 6 years ago
parent
commit
0181b879b0
2 changed files with 24 additions and 21 deletions
  1. +0
    -3
      checks.py
  2. +24
    -18
      err_handle.py

+ 0
- 3
checks.py View File

@@ -2,9 +2,6 @@ from discord.ext import commands
import load_config
from config.server_config import ServerConfig

def is_bot_owner():
return commands.check(lambda ctx: ctx.message.author.id == load_config.owner)

def is_owner_or_admin():
def predicate(ctx):
if ctx.author.id == load_config.owner:

+ 24
- 18
err_handle.py View File

@@ -2,7 +2,6 @@ import traceback
import datetime
import load_config
import discord
from config.server_config import ServerConfig
from discord.ext import commands


@@ -10,11 +9,6 @@ class ErrHandle():
def __init__(self, Bot):
self.bot = Bot
self.dev = True # For debugging
self.slow_mode = False
self.slow_mode_channels = {}
self.users = {}
self.con = ServerConfig()
self.servers = self.con.servers

async def on_error(self, event, *args, **kwargs):
if self.dev:
@@ -22,7 +16,7 @@ class ErrHandle():
else:
embed = discord.Embed(title=':x: Event Error', colour=0xe74c3c) #Red
embed.add_field(name='Event', value=event)
embed.description = '```py\n%s\n```' % traceback.format_exc()
embed.description = '```py\n{}\n```'.format(traceback.format_exc())
embed.timestamp = datetime.datetime.utcnow()
try:
await self.bot.send_message(self.bot.owner_id, embed=embed)
@@ -30,20 +24,13 @@ class ErrHandle():
pass


async def on_command_error(self, error, ctx):
if isinstance(error, commands.NoPrivateMessage):
await self.bot.send_message(ctx.message.author, "This command cannot be used in private messages.")
elif isinstance(error, commands.DisabledCommand):
await self.bot.send_message(ctx.message.channel, content="This command is disabled.")
elif isinstance(error, commands.CheckFailure):
await self.bot.send_message(ctx.message.channel, content="You do not have permission to do this. Back off, thot!")
elif isinstance(error, KeyError):
await self.bot.send_message(ctx.message.channel, content="Belgh")
elif isinstance(error, commands.CommandInvokeError):
async def on_command_error(self, ctx, error):
err_colour = 0x992d22
if isinstance(error, commands.CommandInvokeError):
if self.dev:
raise error
else:
embed = discord.Embed(title=':x: Command Error', colour=0x992d22) #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='Server', value=ctx.message.server)
embed.add_field(name='Channel', value=ctx.message.channel)
@@ -54,6 +41,25 @@ class ErrHandle():
await self.bot.send_message(await self.bot.get_user_info(load_config.owner), embed=embed)
except:
raise error
else:
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)
elif isinstance(error, commands.DisabledCommand):
embed = discord.Embed(description="This command is disabled.", colour=err_colour)
await ctx.send(embed=embed)
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)
elif isinstance(error, commands.MissingRequiredArgument):
embed = discord.Embed(description="This command cannot be used in private messages.", colour=err_colour)
elif isinstance(error, commands.BadArgument):
embed = discord.Embed(description="Invalid Argument given. Please check them.", colour=err_colour)
else:
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)


def setup(Bot):
Bot.add_cog(ErrHandle(Bot))

Loading…
Cancel
Save