From 4842c41b0af04b463b1eb89392b0326e0b646d73 Mon Sep 17 00:00:00 2001 From: wlinator Date: Sun, 4 Aug 2024 13:39:06 -0400 Subject: [PATCH] chore: Update mod-log channel configuration and add info embed --- config/JSON/strings.json | 7 +++++++ modules/config/c_moderation.py | 30 ++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/config/JSON/strings.json b/config/JSON/strings.json index c28809b..0ee23cb 100644 --- a/config/JSON/strings.json +++ b/config/JSON/strings.json @@ -49,6 +49,13 @@ "config_level_type_whimsical": "level announcements will be **sarcastic comments**.", "config_level_type_whimsical_example": "📈 | **lucas** Lol it took you this long to reach **Level 15**.", "config_modlog_channel_set": "moderation logs will be sent in {0}.", + "config_modlog_info_author": "Moderation Log Configuration", + "config_modlog_info_commands_name": "📖 Case commands", + "config_modlog_info_commands_value": "`/cases` - View all cases in this server\n`/case ` - View a specific case\n`/editcase ` - Update a case reason", + "config_modlog_info_description": "This channel has been set as the moderation log channel for **{0}**. All moderation actions issued with Lumi will be logged here as cases.", + "config_modlog_info_warning_name": "⚠️ Warning", + "config_modlog_info_warning_value": "Changing the mod-log channel in the future will make old cases uneditable in this channel.", + "config_modlog_permission_error": "I don't have perms to send messages in that channel. Please fix & try again.", "config_prefix_get": "the current prefix for this server is `{0}`.", "config_prefix_set": "the prefix has been set to `{0}`.", "config_prefix_too_long": "the prefix must be 25 characters or less.", diff --git a/modules/config/c_moderation.py b/modules/config/c_moderation.py index 949ad0d..37396ef 100644 --- a/modules/config/c_moderation.py +++ b/modules/config/c_moderation.py @@ -2,16 +2,42 @@ import discord from lib.embed_builder import EmbedBuilder from lib.constants import CONST from services.moderation.modlog_service import ModLogService +from lib.exceptions.LumiExceptions import LumiException async def set_mod_log_channel(ctx, channel: discord.TextChannel): mod_log = ModLogService() + + info_embed = EmbedBuilder().create_success_embed( + ctx=ctx, + author_text=CONST.STRINGS["config_modlog_info_author"], + description=CONST.STRINGS["config_modlog_info_description"].format( + ctx.guild.name, + ), + show_name=False, + ) + 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(ctx.guild.id, channel.id) - embed = EmbedBuilder().create_success_embed( + success_embed = EmbedBuilder().create_success_embed( ctx=ctx, author_text=CONST.STRINGS["config_author"], description=CONST.STRINGS["config_modlog_channel_set"].format(channel.mention), ) - return await ctx.respond(embed=embed) + return await ctx.respond(embed=success_embed)