From 1c8f55b1ad1a16d8d6ee277785d001c38f17eb3b Mon Sep 17 00:00:00 2001 From: Rafael Almeida Date: Sat, 11 Mar 2023 20:38:44 -0300 Subject: [PATCH] Add No Job Posts context command --- src/commands/context/no-job-posts.ts | 45 ++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/commands/context/no-job-posts.ts diff --git a/src/commands/context/no-job-posts.ts b/src/commands/context/no-job-posts.ts new file mode 100644 index 0000000..ca7e63d --- /dev/null +++ b/src/commands/context/no-job-posts.ts @@ -0,0 +1,45 @@ +import { + ApplicationCommandType, + ContextMenuCommandBuilder, + PermissionFlagsBits, +} from 'discord.js'; +import { ContextMenuCommand } from '../../types'; + +/** + * No Job Posts command + * --- + * Deletes a message and sends a DM to the user telling them to not send job posts + */ + +export const command: ContextMenuCommand = { + data: new ContextMenuCommandBuilder() + .setName('No Job Posts') + .setDMPermission(false) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages) + .setType(ApplicationCommandType.Message), + + async execute(interaction) { + const { targetMessage } = interaction; + const originalMessageContent = targetMessage.content; + + await Promise.all([ + targetMessage.delete(), + targetMessage.author.send({ + content: ` +We currently do not allow job posts in this server, unless it's in the context of a discussion. If you're looking to get hired or to advertise a job vacancy see <#910564441119150100> +Ignoring this warning will result in the account being banned from the server +`, + embeds: [ + { + title: 'Deleted message:', + description: originalMessageContent, + }, + ], + }), + interaction.reply({ + ephemeral: true, + content: 'Ok!', + }), + ]); + }, +};