From 13cb14cba3969b2d621af7c370956130c7b4fad6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl?= <35407363+EniumRaphael@users.noreply.github.com> Date: Mon, 18 Aug 2025 20:17:36 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A6=20Update=20=E2=80=93=20Logs=20Syst?= =?UTF-8?q?em=20Overhaul=20(#33)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(branch/dev): now have a dev branch to test my update * feat(logs/disable): adding the options to disable the logs - Adding the option to the logs command * feat(logs/disable): adding the options to disable the logs - Adding the option to the logs command * feat(logs/disable): finishing the disable command for logs - suppressing all the data stored in database (concerning the logs) - suppressing all the channels on the logs categories --- src/commands/administration/logs.ts | 59 +++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/commands/administration/logs.ts b/src/commands/administration/logs.ts index 9dee44e..ce801f1 100644 --- a/src/commands/administration/logs.ts +++ b/src/commands/administration/logs.ts @@ -37,6 +37,10 @@ export default { name: 'Configuration', value: 'logs_config', }, + { + name: 'Disable', + value: 'logs_disable', + }, ), ), async execute(interaction: CommandInteraction) { @@ -278,6 +282,61 @@ export default { ); break; } + case 'logs_disable': { + if (!userData.isOwner) { + await interaction.reply({ + content: `${emoji.answer.no} | This command is only for owner`, + flags: MessageFlags.Ephemeral, + }); + return; + } + if (!guildData.logEnable) { + await interaction.reply({ + content: `${emoji.answer.error} | The log is not setup on this server`, + flags: MessageFlags.Ephemeral, + }); + return; + } + const category: GuildCategory = await interaction.guild.channels.fetch(guildData.logCategory); + try { + for (const channel of category.children.cache.values()) { + await channel.delete( + `Delete cat of ${channel.name} (by ${interaction.username})`, + ); + } + await category.delete( + `Delete cat of ${category.name} (by ${interaction.username})`, + ); + await interaction.reply({ + content: `${emoji.answer.yes} | Disabled the logs of the guild`, + flags: MessageFlags.Ephemeral, + }); + } + catch (err) { + await interaction.reply({ + content: `${emoji.answer.error} | Cannot suppress the category's channels`, + flags: MessageFlags.Ephemeral, + }); + console.error(`Cannot suppress the category's channel:\n\t${err}`); + return; + } + await prisma.guild.update({ + where: { + id: interaction.guild.id, + }, + data: { + logEnable: false, + logCategory: null, + logBot: null, + logChannels: null, + logMember: null, + logMod: null, + logMsg: null, + logServer: null, + }, + }); + break; + } default: console.error(`no choice on logs command ${choice}`); return;