From bb7240689bc618f62cb17cfaac7aa7517c2f4046 Mon Sep 17 00:00:00 2001 From: "Dusty.P" Date: Wed, 23 May 2018 21:48:54 -0800 Subject: [PATCH] Fixed trout --- exts/admin.py | 16 ++++++++++++++++ exts/fun.py | 5 +++-- exts/utils.py | 17 +++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/exts/admin.py b/exts/admin.py index b14b855..5ad30b8 100644 --- a/exts/admin.py +++ b/exts/admin.py @@ -109,6 +109,7 @@ class Admin: @set.command(name='admin_chan', aliases=['ac', 'admin_chat', 'admin chat']) async def _admin_channel(self, ctx, channel: discord.TextChannel=None): + """Sets the channel for admin specific notifications""" if ctx.guild: if await checks.is_admin(self.bot, ctx): if channel is not None: @@ -118,6 +119,8 @@ class Admin: @set.command(name='channel_lockdown', aliases=['lockdown', 'restrict_access', 'cl']) async def _channel_lockdown(self, ctx, config='true'): + """Toggles the channel lockdown restricting Geeksbot to only access channels defined in allowed_channels + If you run this before configuring allowed_channels it will tell you to run that command first.""" if ctx.guild: if await checks.is_admin(self.bot, ctx): if str(config).lower() == 'true': @@ -143,6 +146,8 @@ class Admin: @add.command(name='allowed_channels', aliases=['channel', 'ac']) async def _allowed_channels(self, ctx, *, channels): + """Allows Admin to restrict what channels Geeksbot is allowed to access + This only takes effect if channel_lockdown is enabled.""" if ctx.guild: if await checks.is_admin(self.bot, ctx): channels = channels.lower().replace(' ', '').split(',') @@ -195,6 +200,10 @@ class Admin: @add.command(aliases=['prefix', 'p']) @commands.cooldown(1, 5, type=commands.BucketType.guild) async def add_prefix(self, ctx, *, prefix=None): + """Adds a guild specific prefix to the guild config + Note: This overwrites the default of g$. If you would + like to keep using g$ you will need to add it to the + Guild config as well.""" if ctx.guild: if await checks.is_admin(self.bot, ctx): prefixes = await self.bot.db_con.fetchval('select prefix from guild_config where guild_id = $1', @@ -224,6 +233,9 @@ class Admin: @remove.command(aliases=['prefix', 'p']) @commands.cooldown(1, 5, type=commands.BucketType.guild) async def remove_prefix(self, ctx, *, prefix=None): + """Removes a guild specific prefix from the guild config + If the last prefix is removed then Geeksbot will default + Back to g$""" if ctx.guild: if await checks.is_admin(self.bot, ctx): prefixes = await self.bot.db_con.fetchval('select prefix from guild_config where guild_id = $1', @@ -260,6 +272,9 @@ class Admin: @commands.cooldown(1, 5, type=commands.BucketType.guild) @commands.check(checks.is_guild_owner) async def _add_admin_role(self, ctx, role=None): + """The Guild owner can add a role to the admin list + Allowing members of that role to run admin commands + on the current guild.""" role = discord.utils.get(ctx.guild.roles, name=role) if role is not None: roles = json.loads(await self.bot.db_con.fetchval('select admin_roles from guild_config ' @@ -278,6 +293,7 @@ class Admin: @commands.cooldown(1, 5, type=commands.BucketType.guild) @commands.check(checks.is_guild_owner) async def _remove_admin_role(self, ctx, role=None): + """The Guild owner can remove a role from the admin list""" role = discord.utils.get(ctx.guild.roles, name=role) if role is not None: roles = json.loads(await self.bot.db_con.fetchval('select admin_roles from guild_config ' diff --git a/exts/fun.py b/exts/fun.py index 4c2f390..c48e64a 100644 --- a/exts/fun.py +++ b/exts/fun.py @@ -65,13 +65,14 @@ class Fun: @commands.command() @commands.cooldown(1, 5, type=commands.BucketType.user) async def slap(self, ctx, member: discord.Member): + trout = await self.bot.db_con.fetchval("select code from geeksbot_emojis where name = 'trout'") if member.id == self.bot.user.id and ctx.author.id != owner_id: await ctx.send(f'You rolled a Critical Fail...\nThe trout bounces off and rebounds on the attacker.') await ctx.send(f'{ctx.author.mention} ' - f'You slap yourself in the face with a large trout <:trout:408543365085397013>') + f'You slap yourself in the face with a large trout {trout}') else: await ctx.send(f'{ctx.author.display_name} slaps ' - f'{member.mention} around a bit with a large trout <:trout:408543365085397013>') + f'{member.mention} around a bit with a large trout {trout}') @staticmethod def get_factorial(number): diff --git a/exts/utils.py b/exts/utils.py index 054539b..5d81f60 100644 --- a/exts/utils.py +++ b/exts/utils.py @@ -59,6 +59,7 @@ class Utils: @commands.command() @commands.is_owner() async def sysinfo(self, ctx): + """WIP Gets current system status for the server that Geeksbot is running on.""" await ctx.send(f'```ml\n' f'CPU Percentages: {psutil.cpu_percent(percpu=True)}\n' f'Memory Usage: {psutil.virtual_memory().percent}%\n' @@ -429,6 +430,8 @@ class Utils: @commands.command(name='localtime', aliases=['time', 'lt']) @commands.cooldown(1, 3, type=commands.BucketType.user) async def get_localtime(self, ctx, timezone: str='Anchorage'): + """Shows the current time localized to the timezone given + This defaults to the Bot's local timezone of Anchorage Alaska USA if none are given.""" em = discord.Embed() try: tz = pytz.timezone(timezone) @@ -453,6 +456,13 @@ class Utils: @commands.command(name='purge', aliases=['clean', 'erase']) @commands.cooldown(1, 3, type=commands.BucketType.user) async def purge_messages(self, ctx, number: int=20, member: discord.Member=None): + """Gives Admin the ability to quickly clear messages from a channel + By default this will only purge messages sent by Geeksbot and any messages that appear to + have called Geeksbot (aka start with one of the Geeksbot's prefixes for this Guild) + If you want to purge messages from a different user you must provide a number and member + + Note: Geeksbot will not find of messages by the given member, it will instead + search the last messages in the channel and delete any by the given member""" def is_me(message): if message.author == self.bot.user: return True @@ -487,6 +497,9 @@ class Utils: @commands.command(name='purge_all', aliases=['cls', 'clear']) @commands.cooldown(1, 3, type=commands.BucketType.user) async def purge_all(self, ctx, number: int=20, contents: str='all'): + """Will delete all of the last of messages from the channel + If is not 'all' then only messages containing + will be deleted.""" if await checks.is_admin(self.bot, ctx): if contents != 'all': deleted = await ctx.channel.purge(limit=number, check=lambda message: message.content == contents) @@ -500,6 +513,7 @@ class Utils: @commands.command(name='google', aliases=['g', 'search']) async def google_search(self, ctx, *, search): + """WIP Search Google for the given string""" res = self.bot.gcs_service.cse().list(q=search, cx=self.bot.bot_secrets['cx']).execute() results = res['items'][:4] em = discord.Embed() @@ -538,6 +552,7 @@ class Utils: @commands.command(name='iss') async def iss_loc(self, ctx): + """WIP Locates the International Space Station and display on a map""" def gen_image(iss_loc): lat = iss_loc['latitude'] lon = iss_loc['longitude'] @@ -561,6 +576,8 @@ class Utils: @commands.command(name='location', aliases=['loc', 'map']) async def map_location(self, ctx, *, location): + """WIP Displays the given location on a map + Note: This is SLOW!!! Be prepared to wait up to a minute for the result""" def draw_map(m, scale=1): # draw a shaded-relief image