From 087114033cb4ca9a966b586dce8f3d8b164f79be Mon Sep 17 00:00:00 2001 From: phxntxm Date: Mon, 8 Oct 2018 15:40:21 -0500 Subject: [PATCH] Add descriptions to classes for help command --- cogs/admin.py | 66 ++++++++++++++++++++++++++++++++++++++++++++ cogs/birthday.py | 2 ++ cogs/blackjack.py | 2 ++ cogs/chess.py | 2 ++ cogs/hangman.py | 2 ++ cogs/images.py | 2 ++ cogs/mod.py | 2 +- cogs/osu.py | 2 ++ cogs/picarto.py | 2 ++ cogs/polls.py | 2 ++ cogs/raffle.py | 2 ++ cogs/roles.py | 2 +- cogs/roulette.py | 1 + cogs/spotify.py | 2 ++ cogs/tictactoe.py | 2 ++ cogs/utils/checks.py | 3 ++ 16 files changed, 94 insertions(+), 2 deletions(-) diff --git a/cogs/admin.py b/cogs/admin.py index b451b7d..49570e3 100644 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -10,9 +10,75 @@ valid_perms = [p for p in dir(discord.Permissions) if isinstance(getattr(discord class Administration: + """Handles the administration of the bot for a server; this is mainly different settings for the bot""" def __init__(self, bot): self.bot = bot + @commands.command() + @commands.guild_only() + @utils.can_run(manage_guild=True) + async def disable(self, ctx, *, command): + """Disables the use of a command on this server""" + if command == "disable" or command == "enable": + await ctx.send("You cannot disable `{}`".format(command)) + return + + cmd = self.bot.get_command(command) + if cmd is None: + await ctx.send("No command called `{}`".format(command)) + return + + from_entry = { + 'source': cmd.qualified_name, + 'destination': "everyone", + } + + restrictions = self.bot.db.load('server_settings', key=ctx.message.guild.id, pluck='restrictions') or {} + _from = restrictions.get('from', []) + if from_entry not in _from: + _from.append(from_entry) + update = { + 'server_id': str(ctx.message.guild.id), + 'restrictions': { + 'from': _from + } + } + await self.bot.db.save('server_settings', update) + await ctx.send("I have disabled `{}`".format(cmd.qualified_name)) + else: + await ctx.send("That command is already disabled") + + @commands.command() + @commands.guild_only() + @utils.can_run(manage_guild=True) + async def enable(self, ctx, *, command): + """Enables the use of a command on this server""" + cmd = self.bot.get_command(command) + if cmd is None: + await ctx.send("No command called `{}`".format(command)) + return + + from_entry = { + 'source': cmd.qualified_name, + 'destination': "everyone", + } + + restrictions = self.bot.db.load('server_settings', key=ctx.message.guild.id, pluck='restrictions') or {} + _from = restrictions.get('from', []) + try: + _from.remove(from_entry) + except ValueError: + await ctx.send("That command is not disabled") + else: + update = { + 'server_id': str(ctx.message.guild.id), + 'restrictions': { + 'from': _from + } + } + await self.bot.db.save('server_settings', update) + await ctx.send("I have enabled `{}`".format(cmd.qualified_name)) + @commands.command() @commands.guild_only() @utils.can_run(manage_guild=True) diff --git a/cogs/birthday.py b/cogs/birthday.py index 05e4cab..f8b3d24 100644 --- a/cogs/birthday.py +++ b/cogs/birthday.py @@ -79,6 +79,8 @@ def parse_string(date): class Birthday: + """Track and announcebirthdays""" + def __init__(self, bot): self.bot = bot self.task = self.bot.loop.create_task(self.birthday_task()) diff --git a/cogs/blackjack.py b/cogs/blackjack.py index ec88f75..5528532 100644 --- a/cogs/blackjack.py +++ b/cogs/blackjack.py @@ -21,6 +21,8 @@ card_map = { class Blackjack: + """Pretty self-explanatory""" + def __init__(self, bot): self.bot = bot self.games = {} diff --git a/cogs/chess.py b/cogs/chess.py index 11a2566..36724ff 100644 --- a/cogs/chess.py +++ b/cogs/chess.py @@ -8,6 +8,8 @@ from enum import Enum class Chess: + """Pretty self-explanatory""" + def __init__(self, bot): self.bot = bot # Our format for games is going to be a little different, because we do want to allow multiple games per guild diff --git a/cogs/hangman.py b/cogs/hangman.py index 2d68251..9ce517a 100644 --- a/cogs/hangman.py +++ b/cogs/hangman.py @@ -65,6 +65,8 @@ class Game: class Hangman: + """Pretty self-explanatory""" + def __init__(self, bot): self.bot = bot self.games = {} diff --git a/cogs/images.py b/cogs/images.py index 40f5359..e26b529 100644 --- a/cogs/images.py +++ b/cogs/images.py @@ -9,6 +9,8 @@ from . import utils class Images: + """Commands that post images, or look up images""" + def __init__(self, bot): self.bot = bot diff --git a/cogs/mod.py b/cogs/mod.py index 5230873..d50a08c 100644 --- a/cogs/mod.py +++ b/cogs/mod.py @@ -7,7 +7,7 @@ import asyncio class Moderation: - """Commands that can be used by a or an admin, depending on the command""" + """Moderation commands, things that help control a server...but not the settings of the server""" def __init__(self, bot): self.bot = bot diff --git a/cogs/osu.py b/cogs/osu.py index 489dae3..0dca59c 100644 --- a/cogs/osu.py +++ b/cogs/osu.py @@ -11,6 +11,8 @@ MAX_RETRIES = 5 class Osu: + """View OSU stats""" + def __init__(self, bot): self.bot = bot self.api = OsuApi(utils.osu_key, connector=AHConnector()) diff --git a/cogs/picarto.py b/cogs/picarto.py index d352fd6..8bd6fad 100644 --- a/cogs/picarto.py +++ b/cogs/picarto.py @@ -11,6 +11,8 @@ BASE_URL = 'https://api.picarto.tv/v1' class Picarto: + """Pretty self-explanatory""" + def __init__(self, bot): self.bot = bot self.task = self.bot.loop.create_task(self.picarto_task()) diff --git a/cogs/polls.py b/cogs/polls.py index f15737b..2fa076f 100644 --- a/cogs/polls.py +++ b/cogs/polls.py @@ -36,6 +36,8 @@ class Poll: class Polls: + """Create custom polls that can be tracked through reactions""" + def __init__(self, bot): self.bot = bot self.polls = [] diff --git a/cogs/raffle.py b/cogs/raffle.py index 6eaa04f..f203711 100644 --- a/cogs/raffle.py +++ b/cogs/raffle.py @@ -11,6 +11,8 @@ import traceback class Raffle: + """Used to hold custom raffles""" + def __init__(self, bot): self.bot = bot self.bot.loop.create_task(self.raffle_task()) diff --git a/cogs/roles.py b/cogs/roles.py index 88e0ed9..902471b 100644 --- a/cogs/roles.py +++ b/cogs/roles.py @@ -85,7 +85,7 @@ class Roles: total_members = len(role.members) embed.add_field(name="Total members", value=str(total_members)) # If there are only a few members in this role, display them - if total_members <= 5: + if total_members <= 5 and total_members > 0: embed.add_field(name="Members", value="\n".join(m.display_name for m in role.members)) await ctx.send(embed=embed) else: diff --git a/cogs/roulette.py b/cogs/roulette.py index e78d564..9df3676 100644 --- a/cogs/roulette.py +++ b/cogs/roulette.py @@ -9,6 +9,7 @@ from . import utils class Roulette: + """A fun game that ends in someone getting kicked!""" def __init__(self, bot): self.bot = bot diff --git a/cogs/spotify.py b/cogs/spotify.py index aac3331..be450ed 100644 --- a/cogs/spotify.py +++ b/cogs/spotify.py @@ -9,6 +9,8 @@ from . import utils class Spotify: + """Pretty self-explanatory""" + def __init__(self, bot): self.bot = bot self._token = None diff --git a/cogs/tictactoe.py b/cogs/tictactoe.py index e05a4cd..5074a9a 100644 --- a/cogs/tictactoe.py +++ b/cogs/tictactoe.py @@ -98,6 +98,8 @@ class Board: class TicTacToe: + """Pretty self-explanatory""" + def __init__(self, bot): self.bot = bot self.boards = {} diff --git a/cogs/utils/checks.py b/cogs/utils/checks.py index 6dfa1ea..ceabe14 100644 --- a/cogs/utils/checks.py +++ b/cogs/utils/checks.py @@ -92,6 +92,9 @@ async def check_not_restricted(ctx): # Source should ALWAYS be a command in this case source = from_restriction.get('source') destination = from_restriction.get('destination') + # Special check for what the "disable" command produces + if destination == "everyone": + return False # Convert destination to the object we want destination = await utilities.convert(ctx, destination) # If we couldn't find the destination, just continue with other restrictions