Skip to content

Commit

Permalink
Added protector role to jail command
Browse files Browse the repository at this point in the history
  • Loading branch information
5jiji committed Oct 29, 2023
1 parent 3e94c53 commit 4136752
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/baseConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ export interface BaseConfig {

start?: (client: ExtendedClient) => any;

jailRole: RoleResolvable,
jail: {
givenRole: RoleResolvable;
protectorRole: RoleResolvable;
},
}

export interface EmojiObject {
Expand Down
5 changes: 4 additions & 1 deletion src/exampleConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ export function start(client: ExtendedClient) {

}

export const jailRole = "";
export const jail = {
givenRole: "974018133037809674",
protectorRole: "",
};
11 changes: 5 additions & 6 deletions src/interactions/Commands/moderation/jail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.**`);
Expand All @@ -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 = \"<role id>\"`?");

let type: "Jail removed" | "Jail added" = "Jail removed";
Expand Down

0 comments on commit 4136752

Please sign in to comment.