From 785eb8eaf2ea2a9b570f08367eedfe3ab2d57889 Mon Sep 17 00:00:00 2001 From: AnxietyisReal <96593068+AnxietyisReal@users.noreply.github.com> Date: Sun, 14 Jan 2024 17:51:17 +1100 Subject: [PATCH] Add /reminder moderation command --- src/commands/reminder.ts | 18 ++++++++++++++++++ src/components/Punish.ts | 2 +- src/models/punishments.ts | 5 +++-- 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 src/commands/reminder.ts diff --git a/src/commands/reminder.ts b/src/commands/reminder.ts new file mode 100644 index 0000000..581548b --- /dev/null +++ b/src/commands/reminder.ts @@ -0,0 +1,18 @@ +import Discord from 'discord.js'; +import TClient from '../client.js'; +import Punish from '../components/Punish.js'; +export default class Reminder { + static run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){ + Punish(client, interaction, 'remind'); + } + static data = new Discord.SlashCommandBuilder() + .setName('reminder') + .setDescription('Remind a member that they\'re breaking the rules') + .addUserOption(x=>x + .setName('member') + .setDescription('Which member to remind?') + .setRequired(true)) + .addStringOption(x=>x + .setName('reason') + .setDescription('Reason for the reminder')) +} diff --git a/src/components/Punish.ts b/src/components/Punish.ts index 4e87e1c..df10240 100644 --- a/src/components/Punish.ts +++ b/src/components/Punish.ts @@ -1,7 +1,7 @@ import Discord from 'discord.js'; import TClient from '../client.js'; import MessageTool from '../helpers/MessageTool.js'; -export default async(client:TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>, type: string)=>{ +export default async(client:TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>, type: 'ban'|'softban'|'kick'|'mute'|'warn'|'remind')=>{ if (!MessageTool.isStaff(interaction.member)) return MessageTool.youNeedRole(interaction, 'dcmod'); const time = interaction.options.getString('time') ?? undefined; diff --git a/src/models/punishments.ts b/src/models/punishments.ts index 130d0b9..03ba4b4 100644 --- a/src/models/punishments.ts +++ b/src/models/punishments.ts @@ -139,7 +139,8 @@ export class PunishmentsSvc { softban: 'softbanned', kick: 'kicked', mute: 'muted', - warn: 'warned' + warn: 'warned', + remind: 'reminded' }[type]; } async punishmentAdd(type:string, options:{time?:string, interaction?:Discord.ChatInputCommandInteraction}, moderator:string, reason: string, user:Discord.User, guildUser?:Discord.GuildMember) { @@ -147,7 +148,7 @@ export class PunishmentsSvc { const now = Date.now(); const guild = this.client.guilds.cache.get(this.client.config.dcServer.id) as Discord.Guild; const punishment:Punishment = {type, case_id: await this.generateCaseId(), member: user.id, reason, moderator, time: now}; - const inOrFromBoolean = ['warn', 'mute'].includes(type) ? 'in' : 'from'; + const inOrFromBoolean = ['warn', 'mute', 'remind'].includes(type) ? 'in' : 'from'; const auditLogReason = `${reason ?? 'Reason unspecified'} | Case #${punishment.case_id}`; const embed = new this.client.embed() .setColor(this.client.config.embedColor)