From 5bb592183e7639d2529b2d49abc4d2f88c349b01 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Wed, 30 Mar 2022 10:59:18 -0600 Subject: [PATCH] Add `notify` setting, fix settings management --- jarvis/cogs/settings.py | 70 +++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 37 deletions(-) diff --git a/jarvis/cogs/settings.py b/jarvis/cogs/settings.py index 88cb3c5..4eebd93 100644 --- a/jarvis/cogs/settings.py +++ b/jarvis/cogs/settings.py @@ -124,79 +124,75 @@ class SettingsCog(Scale): await self.update_settings("noinvite", active, ctx.guild.id) await ctx.send(f"Settings applied. Automatic invite active: {active}") + @set_.subcommand(sub_cmd_name="notify", sub_cmd_description="Notify users of admin action?") + @slash_option(name="active", description="Notify?", opt_type=OptionTypes.BOOLEAN, required=True) + @check(admin_or_permissions(Permissions.MANAGE_GUILD)) + async def _set_notify(self, ctx: InteractionContext, active: bool) -> None: + await ctx.defer() + await self.update_settings("notify", active, ctx.guild.id) + await ctx.send(f"Settings applied. Notifications active: {active}") + # Unset @unset.subcommand( sub_cmd_name="modlog", - sub_cmd_description="Set Moglod channel", - ) - @slash_option( - name="channel", description="ModLog Channel", opt_type=OptionTypes.CHANNEL, required=True + sub_cmd_description="Unset Modlog channel", ) @check(admin_or_permissions(Permissions.MANAGE_GUILD)) - async def _unset_modlog(self, ctx: InteractionContext, channel: GuildText) -> None: + async def _unset_modlog(self, ctx: InteractionContext) -> None: await ctx.defer() - await self.delete_settings("modlog", channel.id, ctx.guild.id) - await ctx.send(f"Setting `{channel.mention}` unset") + await self.delete_settings("modlog") + await ctx.send("Setting `modlog` unset") @unset.subcommand( sub_cmd_name="activitylog", - sub_cmd_description="Set Activitylog channel", - ) - @slash_option( - name="channel", - description="Activitylog Channel", - opt_type=OptionTypes.CHANNEL, - required=True, + sub_cmd_description="Unset Activitylog channel", ) @check(admin_or_permissions(Permissions.MANAGE_GUILD)) - async def _unset_activitylog(self, ctx: InteractionContext, channel: GuildText) -> None: + async def _unset_activitylog(self, ctx: InteractionContext) -> None: await ctx.defer() - await self.delete_settings("activitylog", channel.id, ctx.guild.id) - await ctx.send(f"Setting `{channel.mention}` unset") + await self.delete_settings("activitylog") + await ctx.send("Setting `activitylog` unset") - @unset.subcommand(sub_cmd_name="massmention", sub_cmd_description="Set massmention output") - @slash_option( - name="amount", - description="Amount of mentions (0 to disable)", - opt_type=OptionTypes.INTEGER, - required=True, - ) + @unset.subcommand(sub_cmd_name="massmention", sub_cmd_description="Unset massmention output") @check(admin_or_permissions(Permissions.MANAGE_GUILD)) - async def _unset_massmention(self, ctx: InteractionContext, amount: int) -> None: + async def _unset_massmention(self, ctx: InteractionContext) -> None: await ctx.defer() await self.delete_settings("massmention") - await ctx.send(f"Setting `{amount}` unset") + await ctx.send("Setting `massmention` unset") - @unset.subcommand(sub_cmd_name="verified", sub_cmd_description="Set verified role") + @unset.subcommand(sub_cmd_name="verified", sub_cmd_description="Unset verified role") @slash_option( name="role", description="Verified role", opt_type=OptionTypes.ROLE, required=True ) @check(admin_or_permissions(Permissions.MANAGE_GUILD)) - async def _unset_verified(self, ctx: InteractionContext, role: Role) -> None: + async def _unset_verified(self, ctx: InteractionContext) -> None: await ctx.defer() await self.delete_settings("verified") - await ctx.send(f"Setting `{role.name} unset`") + await ctx.send("Setting `massmention` unset") - @unset.subcommand(sub_cmd_name="unverified", sub_cmd_description="Set unverified role") - @slash_option( - name="role", description="Unverified role", opt_type=OptionTypes.ROLE, required=True - ) + @unset.subcommand(sub_cmd_name="unverified", sub_cmd_description="Unset unverified role") @check(admin_or_permissions(Permissions.MANAGE_GUILD)) - async def _unset_unverified(self, ctx: InteractionContext, role: Role) -> None: + async def _unset_unverified(self, ctx: InteractionContext) -> None: await ctx.defer() await self.delete_settings("unverified") - await ctx.send(f"Setting `{role.name}` unset") + await ctx.send("Setting `unverified` unset") @unset.subcommand( - sub_cmd_name="noinvite", sub_cmd_description="Set if invite deletion should happen" + sub_cmd_name="noinvite", sub_cmd_description="Unset if invite deletion should happen" ) - @slash_option(name="active", description="Active?", opt_type=OptionTypes.BOOLEAN, required=True) @check(admin_or_permissions(Permissions.MANAGE_GUILD)) async def _unset_invitedel(self, ctx: InteractionContext, active: bool) -> None: await ctx.defer() await self.delete_settings("noinvite") await ctx.send(f"Setting `{active}` unset") + @unset.subcommand(sub_cmd_name="notify", sub_cmd_description="Unset admin action notifications") + @check(admin_or_permissions(Permissions.MANAGE_GUILD)) + async def _unset_notify(self, ctx: InteractionContext) -> None: + await ctx.defer() + await self.delete_settings("noinvite") + await ctx.send("Setting `notify` unset") + @settings.subcommand(sub_cmd_name="view", sub_cmd_description="View settings") @check(admin_or_permissions(Permissions.MANAGE_GUILD)) async def _view(self, ctx: InteractionContext) -> None: