From 7cee33315c942a2cba72e3334d1da0f18c83b752 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Mon, 19 Jul 2021 13:13:46 -0600 Subject: [PATCH] Close #51, fix starboard channel restrictions --- jarvis/cogs/admin.py | 3 +++ jarvis/cogs/settings.py | 4 +++- jarvis/cogs/starboard.py | 13 ++++++++----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/jarvis/cogs/admin.py b/jarvis/cogs/admin.py index f299775..9f04a47 100644 --- a/jarvis/cogs/admin.py +++ b/jarvis/cogs/admin.py @@ -1011,6 +1011,9 @@ class AdminCog(commands.Cog): async def _autopurge_add( self, ctx: SlashContext, channel: TextChannel, delay: int = 30 ): + if not isinstance(channel, TextChannel): + await ctx.send("Channel must be a TextChannel", hidden=True) + return autopurge = self.db.jarvis.autopurge.find( {"guild": ctx.guild.id, "channel": channel.id} ) diff --git a/jarvis/cogs/settings.py b/jarvis/cogs/settings.py index 88f4e63..2840e94 100644 --- a/jarvis/cogs/settings.py +++ b/jarvis/cogs/settings.py @@ -61,7 +61,9 @@ class SettingsCog(commands.Cog): ) @commands.has_permissions(administrator=True) async def _modlog(self, ctx, channel: TextChannel): - await ctx.defer() + if not isinstance(channel, TextChannel): + await ctx.send("Channel must be a TextChannel", hidden=True) + return self.update_settings("modlog", channel.id, ctx.guild.id) await ctx.send( f"Settings applied. New modlog channel is {channel.mention}" diff --git a/jarvis/cogs/starboard.py b/jarvis/cogs/starboard.py index 68849e2..1649c2a 100644 --- a/jarvis/cogs/starboard.py +++ b/jarvis/cogs/starboard.py @@ -68,6 +68,9 @@ class StarboardCog(commands.Cog): hidden=True, ) return + if not isinstance(target, TextChannel): + await ctx.send("Target must be a TextChannel", hidden=True) + return exists = self.db.jarvis.starboard.find_one( {"target": target.id, "guild": ctx.guild.id} ) @@ -101,21 +104,21 @@ class StarboardCog(commands.Cog): ], ) @commands.has_permissions(administrator=True) - async def _delete(self, ctx, target: TextChannel): + async def _delete(self, ctx, channel: TextChannel): deleted = self.db.jarvis.starboard.delete_one( { - "target": target.id, + "target": channel.id, "guild": ctx.guild.id, } ) if deleted: - self.db.jarvis.stars.delete_many({"starboard": target.id}) + self.db.jarvis.stars.delete_many({"starboard": channel.id}) await ctx.send( - f"Starboard deleted from {target.mention}.", hidden=True + f"Starboard deleted from {channel.mention}.", hidden=True ) else: await ctx.send( - f"Starboard not found in {target.mention}.", hidden=True + f"Starboard not found in {channel.mention}.", hidden=True ) @cog_ext.cog_subcommand(