From b247a0957b460775213fd0dcc6ad7d67779f1846 Mon Sep 17 00:00:00 2001 From: AnxietyisReal <96593068+AnxietyisReal@users.noreply.github.com> Date: Sun, 7 Jan 2024 16:35:04 +1100 Subject: [PATCH] Add webhook notification in add/remove commands --- src/commands/prohibitedWords.ts | 20 ++++++++++++++++++++ src/config.json | 5 +++-- src/interfaces.d.ts | 1 + 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/commands/prohibitedWords.ts b/src/commands/prohibitedWords.ts index eb4ecd1..ce7f8bb 100644 --- a/src/commands/prohibitedWords.ts +++ b/src/commands/prohibitedWords.ts @@ -1,5 +1,6 @@ import Discord from 'discord.js'; import TClient from '../client.js'; +import HookMgr from '../components/HookManager.js'; import MessageTool from '../helpers/MessageTool.js'; export default class ProhibitedWords { static async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){ @@ -22,6 +23,14 @@ export default class ProhibitedWords { else { await client.prohibitedWords.insertWord(word); interaction.reply({ephemeral: true, content: `Successfully added \`${word}\` to the list`}); + await this.notify(client, { + embeds: [new client.embed() + .setColor(client.config.embedColorGreen) + .setDescription(`**${interaction.user.tag}** has added \`${word}\` to the list`) + .setFooter({text: `Total: ${(await client.prohibitedWords.getAllWords()).length}`}) + .setAuthor({name: interaction.user.tag, iconURL: interaction.user.displayAvatarURL({size: 2048})}) + ] + }); } }, remove: async()=>{ @@ -29,6 +38,14 @@ export default class ProhibitedWords { else { await client.prohibitedWords.removeWord(word); interaction.reply({ephemeral: true, content: `Successfully removed \`${word}\` from the list`}); + await this.notify(client, { + embeds: [new client.embed() + .setColor(client.config.embedColorRed) + .setDescription(`**${interaction.user.tag}** has removed \`${word}\` from the list`) + .setFooter({text: `Total: ${(await client.prohibitedWords.getAllWords()).length}`}) + .setAuthor({name: interaction.user.tag, iconURL: interaction.user.displayAvatarURL({size: 2048})}) + ] + }); } }, import: async()=>{ @@ -40,6 +57,9 @@ export default class ProhibitedWords { } } as any)[interaction.options.getSubcommand()](); } + private static async notify(client:TClient, message:Discord.MessageCreateOptions) { + return new HookMgr(client, 'pw_list', '1193424631059714128').send(message); + } static data = new Discord.SlashCommandBuilder() .setName('pw') .setDescription('Manage the database of prohibited words') diff --git a/src/config.json b/src/config.json index 02e0818..3133c46 100644 --- a/src/config.json +++ b/src/config.json @@ -84,7 +84,8 @@ "punishment_log": "1102751034754998302", "dcmod_chat": "742324777934520350", "mpmod_chat": "516344221452599306", - "multifarm_chat": "1149238561934151690" + "multifarm_chat": "1149238561934151690", + "pw_list": "1193424588554645505" } } -} \ No newline at end of file +} diff --git a/src/interfaces.d.ts b/src/interfaces.d.ts index 543a824..c46f3e9 100644 --- a/src/interfaces.d.ts +++ b/src/interfaces.d.ts @@ -159,6 +159,7 @@ export interface Config { dcmod_chat: string, mpmod_chat: string, multifarm_chat: string + pw_list: string } } }