Skip to content

Add No Job Posts context command #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/commands/context/no-job-posts.ts
Original file line number Diff line number Diff line change
@@ -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!',
}),
]);
},
};