From 41367524c3575c1c31a118effdf6b9e90535ab04 Mon Sep 17 00:00:00 2001 From: 5jiji Date: Sun, 29 Oct 2023 22:46:07 +0100 Subject: [PATCH] Added protector role to jail command --- src/baseConfig.ts | 5 ++++- src/exampleConfig.ts | 5 ++++- src/interactions/Commands/moderation/jail.ts | 11 +++++------ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/baseConfig.ts b/src/baseConfig.ts index 0623b07..64ea85b 100755 --- a/src/baseConfig.ts +++ b/src/baseConfig.ts @@ -41,7 +41,10 @@ export interface BaseConfig { start?: (client: ExtendedClient) => any; - jailRole: RoleResolvable, + jail: { + givenRole: RoleResolvable; + protectorRole: RoleResolvable; + }, } export interface EmojiObject { diff --git a/src/exampleConfig.ts b/src/exampleConfig.ts index 4583878..3180cae 100755 --- a/src/exampleConfig.ts +++ b/src/exampleConfig.ts @@ -38,4 +38,7 @@ export function start(client: ExtendedClient) { } -export const jailRole = ""; \ No newline at end of file +export const jail = { + givenRole: "974018133037809674", + protectorRole: "", +}; \ No newline at end of file diff --git a/src/interactions/Commands/moderation/jail.ts b/src/interactions/Commands/moderation/jail.ts index c65ac9d..9bedc1e 100755 --- a/src/interactions/Commands/moderation/jail.ts +++ b/src/interactions/Commands/moderation/jail.ts @@ -30,6 +30,9 @@ class Jail extends Interaction { const guild = await client.guilds.fetch(interaction.guildId); const member = await guild.members.fetch({ user: user.id, force: true }); + + if (typeof client.config?.jail.protectorRole === "string" && member.roles.cache.has(client.config.jail.protectorRole)) return interaction.followUp({content: `User has protected role <@&${client.config.jail.protectorRole}>`, allowedMentions: {parse: []}}); + const db = { cases: client.db?.cases, jailed: client.db?.jailed @@ -40,11 +43,7 @@ class Jail extends Interaction { const avatar = user.avatarURL({ extension: "png", size: 4096 }) || undefined; const username = escapeMarkdown(user.discriminator !== "#0" ? user.username : `${user.username}#${user.discriminator}`); const execUsername = escapeMarkdown(interaction.user.discriminator !== "#0" ? interaction.user.username : `${interaction.user.username}#${interaction.user.discriminator}`); - /* - const dmEmbed = new EmbedBuilder() - .setColor("#f0ac47") - .setDescription(`**You have been jailed from ${guild.name} for**: ${reason}`); - */ + const replyEmbed = new EmbedBuilder() .setColor("#43b582") .setDescription(`**${username} (${user.id}) has been unjailed.**`); @@ -58,7 +57,7 @@ class Jail extends Interaction { { name: "**Reason**", value: escapeMarkdown(reason), inline: true } ); - const jailRole = client.config?.jailRole; + const jailRole = client.config?.jail.givenRole; if (!jailRole) return interaction.followUp("No jailed role found in the config.\n Did you put `export const jailRole = \"\"`?"); let type: "Jail removed" | "Jail added" = "Jail removed";