Skip to content
This repository has been archived by the owner on Oct 12, 2024. It is now read-only.

Commit

Permalink
Send ban appeal link if user got banned and can appeal
Browse files Browse the repository at this point in the history
Closes #20
  • Loading branch information
RealEthanPlayzDev committed Feb 5, 2024
1 parent 2d09fab commit 872de80
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
1 change: 1 addition & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ model Guild {
LoggingChannelId String @default("")
JoinLeaveLogChannelId String @default("")
CurrentCaseId Int @default(0)
BanAppealLink String @default("")
}

enum ModerationAction {
Expand Down
19 changes: 18 additions & 1 deletion src/commands/Moderation/Ban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,26 @@ export const Command: MeteoriumCommand = {
.setTimestamp()
.setColor("Red");

const AppealEmbed = new MeteoriumEmbedBuilder(undefined, User)
.setTitle(NotAppealable ? "You cannot appeal your ban." : "Your ban is appealable.")
.setDescription(
NotAppealable
? "Your ban was marked unappealable, you have been permanently banned."
: GuildSchema.BanAppealLink != ""
? "You can appeal your ban, use the following link below to appeal."
: "You can appeal your ban, contact a server moderator.",
);

if (NotAppealable) AppealEmbed.setErrorColor();
else {
AppealEmbed.setColor("Yellow");
if (GuildSchema.BanAppealLink != "")
AppealEmbed.addFields([{ name: "Ban appeal link", value: GuildSchema.BanAppealLink }]);
}

try {
const DirectMessageChannnel = await User.createDM();
await DirectMessageChannnel.send({ embeds: [LogEmbed] });
await DirectMessageChannnel.send({ embeds: [LogEmbed, AppealEmbed] });
} catch (err) {
client.Logging.GetNamespace("Moderation/Ban").warn(`Could not dm ${User.id}\n${err}`);
}
Expand Down
34 changes: 34 additions & 0 deletions src/commands/Moderation/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ export const Command: MeteoriumCommand = {
.setDescription("The channel where moderation logs will be sent at")
.setRequired(true),
),
)
.addSubcommand((subcommand) =>
subcommand
.setName("banappeallink")
.setDescription(
"The ban appeals link, sent to people who got banned in dms if they can appeal.",
)
.addStringOption((option) =>
option
.setName("link")
.setDescription("The link for the ban appeal form. Don't specify to unset.")
.setRequired(false),
),
),
)
.addSubcommandGroup((subcommandgroup) =>
Expand Down Expand Up @@ -216,6 +229,27 @@ export const Command: MeteoriumCommand = {
});
break;
}
case "banappeallink": {
const Link = interaction.options.getString("link", false) || "";
client.Database.guild
.update({
where: { GuildId: GuildSchema.GuildId },
data: { BanAppealLink: Link },
})
.then(async () => {
return await interaction.editReply({
content: `Successfully configured \`\`banappeallink\`\` setting (new value is ${Link})`,
});
})
.catch(async (err) => {
settingsNS.error(`Error while update guild configuration:\n${err}`);
return await interaction.editReply({
content:
"An error occured while updating the guild configuration. Please try again later.",
});
});
break;
}
default:
break;
}
Expand Down

0 comments on commit 872de80

Please sign in to comment.