feat: added configuration for logging channels
This commit is contained in:
parent
63c764b6cc
commit
00dc0211c3
1 changed files with 44 additions and 4 deletions
|
@ -11,7 +11,8 @@ class Shortmute(commands.Cog):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.config = Config.get_conf(self, identifier=25781647388294, force_registration=True)
|
self.config = Config.get_conf(self, identifier=25781647388294, force_registration=True)
|
||||||
self.config.register_guild(
|
self.config.register_guild(
|
||||||
dm = True
|
dm = True,
|
||||||
|
logging_channels = []
|
||||||
)
|
)
|
||||||
|
|
||||||
@app_commands.command()
|
@app_commands.command()
|
||||||
|
@ -106,9 +107,48 @@ class Shortmute(commands.Cog):
|
||||||
message = await self.passed_info['interaction'].edit_original_response(content="Command cancelled.", view=None, embed=None)
|
message = await self.passed_info['interaction'].edit_original_response(content="Command cancelled.", view=None, embed=None)
|
||||||
await message.delete(delay=3)
|
await message.delete(delay=3)
|
||||||
|
|
||||||
@commands.command()
|
@commands.group(name='shortmuteset', autohelp=True)
|
||||||
async def shortmute_dm(self, ctx: commands.Context, enabled: bool = None):
|
@commands.guild_only()
|
||||||
"""This command changes if the `/shortmute` slash command Direct Messages its' target."""
|
async def shortmute_config(self, ctx: commands.Context):
|
||||||
|
"""This command group is used to configure the `/shortmute` slash command."""
|
||||||
|
|
||||||
|
@shortmute_config.command(name='addchannel')
|
||||||
|
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')
|
||||||
|
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')
|
||||||
|
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()
|
old_value = await self.config.guild(ctx.guild.id).dm()
|
||||||
if enabled:
|
if enabled:
|
||||||
await self.config.guild(ctx.guild.id).dm.set(enabled)
|
await self.config.guild(ctx.guild.id).dm.set(enabled)
|
||||||
|
|
Loading…
Reference in a new issue