Browse Source

Added an exception in the error handling so that commandnotfound doesnt trigger when using a custom command

tags/v1.4.0
roxie 6 years ago
parent
commit
2231d0df5f
2 changed files with 11 additions and 5 deletions
  1. +1
    -1
      cogs/customcommands.py
  2. +10
    -4
      err_handle.py

+ 1
- 1
cogs/customcommands.py View File

@@ -23,7 +23,7 @@ class CustomCommands():
return
msg = message.content.lower()
channel = message.channel
server = message.server.id
server = str(message.server.id)
if message.author == self.bot.user:
return
if msg.startswith(self.bot.command_prefix):

+ 10
- 4
err_handle.py View File

@@ -2,12 +2,13 @@ import traceback
import datetime
import discord
from discord.ext import commands
from config.server_config import ServerConfig

class ErrHandle:
def __init__(self, bot_client):
self.bot = bot_client
self.dev = True # For debugging
self.servers = ServerConfig().servers

async def on_error(self, event, *args, **kwargs):
if self.dev:
@@ -50,7 +51,11 @@ class ErrHandle:
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.")
cc = self.servers[str(ctx.guild.id)]["custom_commands"]
if ctx.invoked_with in cc["1"]:
embed = None
else:
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):
@@ -62,8 +67,9 @@ class ErrHandle:
else:
embed = discord.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)
if embed:
embed.colour = err_colour
await ctx.send(embed=embed, delete_after=10)


def setup(bot_client):

Loading…
Cancel
Save