feat: add tag mentions and deletions

This commit is contained in:
Ryan Cao 2022-09-12 15:01:26 +08:00
parent 6673a8a36c
commit ff5882730d
No known key found for this signature in database
3 changed files with 38 additions and 2 deletions

View file

@ -1,4 +1,10 @@
import { Client, GatewayIntentBits, Partials, OAuth2Scopes } from 'discord.js';
import {
Client,
GatewayIntentBits,
Partials,
OAuth2Scopes,
InteractionType,
} from 'discord.js';
import { reuploadCommands } from './_reupload';
import * as BuildConfig from './constants';
@ -125,6 +131,26 @@ client.on('interactionCreate', async (interaction) => {
}
});
client.on('messageReactionAdd', async (reaction, user) => {
if (reaction.partial) {
try {
await reaction.fetch();
} catch (error) {
console.error('Something went wrong when fetching the message:', error);
return;
}
}
if (
reaction.message.interaction &&
reaction.message.interaction?.type === InteractionType.ApplicationCommand &&
reaction.message.interaction?.user === user &&
reaction.emoji.name === '❌'
) {
await reaction.message.delete();
}
});
reuploadCommands()
.then(() => {
client.login(process.env.DISCORD_TOKEN);