diff options
| -rw-r--r-- | bot/cogs/free.py | 29 | ||||
| -rw-r--r-- | bot/cogs/help.py | 6 | ||||
| -rw-r--r-- | bot/constants.py | 3 | ||||
| -rw-r--r-- | bot/decorators.py | 2 |
4 files changed, 11 insertions, 29 deletions
diff --git a/bot/cogs/free.py b/bot/cogs/free.py index 620449f7e..fd6009bb8 100644 --- a/bot/cogs/free.py +++ b/bot/cogs/free.py @@ -2,10 +2,10 @@ import logging from datetime import datetime from discord import Colour, Embed, Member, utils -from discord.ext import commands -from discord.ext.commands import BucketType, Context, command, cooldown +from discord.ext.commands import Context, command -from bot.constants import Categories, Free, Roles +from bot.constants import Categories, Channels, Free, STAFF_ROLES +from bot.decorators import redirect_output log = logging.getLogger(__name__) @@ -21,7 +21,7 @@ class Free: PYTHON_HELP_ID = Categories.python_help @command(name="free", aliases=('f',)) - @cooldown(RATE, PER, BucketType.channel) + @redirect_output(destination_channel=Channels.bot, bypass_roles=STAFF_ROLES) async def free(self, ctx: Context, user: Member = None, seek: int = 2): """ Lists free help channels by likeliness of availability. @@ -100,27 +100,6 @@ class Free: await ctx.send(embed=embed) - @free.error - async def free_error(self, ctx: Context, error): - """ - If error raised is CommandOnCooldown, and the - user who invoked has the helper role, reset - the cooldown and reinvoke the command. - - Otherwise log the error. - """ - helpers = ctx.guild.get_role(Roles.helpers) - - if isinstance(error, commands.CommandOnCooldown): - if helpers in ctx.author.roles: - # reset cooldown so second invocation - # doesn't bring us back here. - ctx.command.reset_cooldown(ctx) - # return to avoid needlessly logging the error - return await ctx.reinvoke() - - log.exception(error) # Don't ignore other errors - def setup(bot): bot.add_cog(Free()) diff --git a/bot/cogs/help.py b/bot/cogs/help.py index 2168e2a60..20ed08f07 100644 --- a/bot/cogs/help.py +++ b/bot/cogs/help.py @@ -10,7 +10,7 @@ from discord.ext.commands import CheckFailure from fuzzywuzzy import fuzz, process from bot import constants -from bot.constants import Roles +from bot.constants import Channels, STAFF_ROLES from bot.decorators import redirect_output from bot.pagination import ( DELETE_EMOJI, FIRST_EMOJI, LAST_EMOJI, @@ -25,7 +25,7 @@ REACTIONS = { LAST_EMOJI: 'end', DELETE_EMOJI: 'stop' } -STAFF_ROLES = Roles.helpers, Roles.moderator, Roles.admin, Roles.owner + Cog = namedtuple('Cog', ['name', 'description', 'commands']) @@ -654,7 +654,7 @@ class Help: Custom Embed Pagination Help feature """ @commands.command('help') - @redirect_output(constants.Channels.bot, STAFF_ROLES) + @redirect_output(destination_channel=Channels.bot, bypass_roles=STAFF_ROLES) async def new_help(self, ctx, *commands): """ Shows Command Help. diff --git a/bot/constants.py b/bot/constants.py index f23696e4d..b4c9b6f11 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -496,6 +496,9 @@ DEBUG_MODE = True if 'local' in os.environ.get("SITE_URL", "local") else False BOT_DIR = os.path.dirname(__file__) PROJECT_ROOT = os.path.abspath(os.path.join(BOT_DIR, os.pardir)) +# Default role combinations +STAFF_ROLES = Roles.helpers, Roles.moderator, Roles.admin, Roles.owner + # Bot replies NEGATIVE_REPLIES = [ "Noooooo!!", diff --git a/bot/decorators.py b/bot/decorators.py index ce54f28cd..0e372671a 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -122,7 +122,7 @@ def redirect_output(destination_channel: int, bypass_roles: typing.Container[int redirect_channel = ctx.guild.get_channel(destination_channel) old_channel = ctx.channel - log.trace(f"Redirecting output of {ctx.author}'s command '{ctx.command.name}'' to {redirect_channel.name}") + log.trace(f"Redirecting output of {ctx.author}'s command '{ctx.command.name}' to {redirect_channel.name}") ctx.channel = redirect_channel await ctx.channel.send(f"Here's the output of your command, {ctx.author.mention}") await func(self, ctx, *args, **kwargs) |