diff --git a/shortmute/shortmute.py b/shortmute/shortmute.py index 4548289..5ce566e 100644 --- a/shortmute/shortmute.py +++ b/shortmute/shortmute.py @@ -114,56 +114,56 @@ class Shortmute(commands.Cog): message = await self.passed_info['interaction'].edit_original_response(content="Command cancelled.", view=None, embed=None) await message.delete(delay=3) - @commands.group(name='shortmuteset', autohelp=True) - @commands.guild_only() - async def shortmute_config(self, ctx: commands.Context): - """This command group is used to configure the `/shortmute` slash command.""" + @commands.group(name='shortmuteset', autohelp=True) + @commands.guild_only() + async def shortmute_config(self, ctx: commands.Context): + """This command group is used to configure the `/shortmute` slash command.""" - @shortmute_config.command(name='addchannel') - @commands.guild_only() - async def shortmute_config_addchannel(self, ctx: commands.Context, channel: discord.TextChannel = None): - """This command changes where the `/shortmute` slash command will log shortmutes. You can set multiple channels as well!""" - current_list = await self.config.guild(ctx.guild.id).logging_channels() - if channel: - if channel.id in current_list: - await ctx.send("This channel is already in the logging channel list!") - return - else: - current_list.append(channel.id) - await self.config.guild(ctx.guild.id).logging_channels.set(current_list) - await ctx.send(f"{channel.mention} has been added to the logging channels list.") - else: - already_in_list = [] - for channel_id in current_list: - channel_obj = ctx.guild.get_channel(channel_id) - if channel_obj: - already_in_list.append(channel_obj.mention) - if already_in_list: - await ctx.send("Channels already in the list:\n" + "\n".join(already_in_list)) - else: - await ctx.send("Please provide a valid channel.") - - @shortmute_config.command(name='removechannel') - @commands.guild_only() - async def shortmute_config_removechannel(self, ctx: commands.Context, channel: discord.TextChannel = None): - """This command removes a channel from the `/shortmute`slash command's logging channels list.""" - current_list = await self.config.guild(ctx.guild.id).logging_channels() + @shortmute_config.command(name='addchannel') + @commands.guild_only() + async def shortmute_config_addchannel(self, ctx: commands.Context, channel: discord.TextChannel = None): + """This command changes where the `/shortmute` slash command will log shortmutes. You can set multiple channels as well!""" + current_list = await self.config.guild(ctx.guild.id).logging_channels() + if channel: if channel.id in current_list: - current_list.remove(channel.id) - await self.config.guild(ctx.guild.id).logging_channels.set(current_list) - await ctx.send(f"{channel.mention} has been removed from the logging channels list.") + await ctx.send("This channel is already in the logging channel list!") + return else: - await ctx.send("Please provide a valid channel that exists in the logging channels list.") + current_list.append(channel.id) + await self.config.guild(ctx.guild.id).logging_channels.set(current_list) + await ctx.send(f"{channel.mention} has been added to the logging channels list.") + else: + already_in_list = [] + for channel_id in current_list: + channel_obj = ctx.guild.get_channel(channel_id) + if channel_obj: + already_in_list.append(channel_obj.mention) + if already_in_list: + await ctx.send("Channels already in the list:\n" + "\n".join(already_in_list)) + else: + await ctx.send("Please provide a valid channel.") - @shortmute_config.command(name='dm') - @commands.guild_only() - async def shortmute_config_dm(self, ctx: commands.Context, enabled: bool = None): - """This command changes if the `/shortmute` slash command Direct Messages its target.""" - old_value = await self.config.guild(ctx.guild.id).dm() - if enabled: - await self.config.guild(ctx.guild.id).dm.set(enabled) - await ctx.send(content=f"Shortmute Direct Message setting changed!\nOld value: `{old_value}`\nNew value: `{enabled}`") - elif old_value is True: - await ctx.send(content="Shortmute Direct Messages are currently enabled!") - elif old_value is False: - await ctx.send(content="Shortmute Direct Messages are currently disabled!") + @shortmute_config.command(name='removechannel') + @commands.guild_only() + async def shortmute_config_removechannel(self, ctx: commands.Context, channel: discord.TextChannel = None): + """This command removes a channel from the `/shortmute`slash command's logging channels list.""" + current_list = await self.config.guild(ctx.guild.id).logging_channels() + if channel.id in current_list: + current_list.remove(channel.id) + await self.config.guild(ctx.guild.id).logging_channels.set(current_list) + await ctx.send(f"{channel.mention} has been removed from the logging channels list.") + else: + await ctx.send("Please provide a valid channel that exists in the logging channels list.") + + @shortmute_config.command(name='dm') + @commands.guild_only() + async def shortmute_config_dm(self, ctx: commands.Context, enabled: bool = None): + """This command changes if the `/shortmute` slash command Direct Messages its target.""" + old_value = await self.config.guild(ctx.guild.id).dm() + if enabled: + await self.config.guild(ctx.guild.id).dm.set(enabled) + await ctx.send(content=f"Shortmute Direct Message setting changed!\nOld value: `{old_value}`\nNew value: `{enabled}`") + elif old_value is True: + await ctx.send(content="Shortmute Direct Messages are currently enabled!") + elif old_value is False: + await ctx.send(content="Shortmute Direct Messages are currently disabled!")