From 64d49d3181e5799edf88371d7c862526d54259b1 Mon Sep 17 00:00:00 2001 From: wlinator Date: Fri, 30 Aug 2024 05:15:17 -0400 Subject: [PATCH] feat: Add /config mod log command --- modules/config/config.py | 52 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/modules/config/config.py b/modules/config/config.py index a4301c5..1c65587 100644 --- a/modules/config/config.py +++ b/modules/config/config.py @@ -4,6 +4,7 @@ from discord.ext import commands import lib.format from lib.const import CONST +from lib.exceptions import LumiException from services.config_service import GuildConfig from services.modlog_service import ModLogService from ui.config import create_boost_embed, create_greet_embed @@ -605,6 +606,57 @@ class Config(commands.GroupCog, group_name="config"): await interaction.response.send_message(embed=embed) + @moderation.command(name="log") + async def set_mod_log_channel(self, interaction: discord.Interaction, channel: discord.TextChannel) -> None: + """ + Set the moderation log channel for the server. + + Parameters + ---------- + interaction : discord.Interaction + The interaction to set the moderation log channel for. + channel : discord.TextChannel + The channel to set as the moderation log channel. + """ + assert interaction.guild + mod_log = ModLogService() + + info_embed = Builder.create_embed( + theme="info", + user_name=interaction.user.name, + author_text=CONST.STRINGS["config_modlog_info_author"], + description=CONST.STRINGS["config_modlog_info_description"].format( + interaction.guild.name, + ), + hide_name_in_description=True, + ) + info_embed.add_field( + name=CONST.STRINGS["config_modlog_info_commands_name"], + value=CONST.STRINGS["config_modlog_info_commands_value"], + inline=False, + ) + info_embed.add_field( + name=CONST.STRINGS["config_modlog_info_warning_name"], + value=CONST.STRINGS["config_modlog_info_warning_value"], + inline=False, + ) + + try: + await channel.send(embed=info_embed) + except discord.errors.Forbidden as e: + raise LumiException(CONST.STRINGS["config_modlog_permission_error"]) from e + + mod_log.set_modlog_channel(interaction.guild.id, channel.id) + + success_embed = Builder.create_embed( + theme="success", + user_name=interaction.user.name, + author_text=CONST.STRINGS["config_author"], + description=CONST.STRINGS["config_modlog_channel_set"].format(channel.mention), + ) + + await interaction.response.send_message(embed=success_embed) + async def setup(bot: commands.Bot) -> None: await bot.add_cog(Config(bot))