/[sudobot]/trunk/src/commands/moderation/NotedelCommand.ts
ViewVC logotype

Annotation of /trunk/src/commands/moderation/NotedelCommand.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 344 - (hide annotations)
Mon Jul 29 17:29:40 2024 UTC (8 months, 2 weeks ago) by rakin
File MIME type: application/typescript
File size: 1787 byte(s)
chore: eslint autofix
1 rakin 344 import { CommandInteraction, Message } from 'discord.js';
2 rakin 51 import BaseCommand from '../../utils/structures/BaseCommand';
3     import DiscordClient from '../../client/Client';
4     import CommandOptions from '../../types/CommandOptions';
5     import InteractionOptions from '../../types/InteractionOptions';
6     import MessageEmbed from '../../client/MessageEmbed';
7 rakin 86 import Note from '../../models/Note';
8     import { fetchEmojiStr } from '../../utils/Emoji';
9 rakin 51
10     export default class NotedelCommand extends BaseCommand {
11     supportsInteractions: boolean = true;
12    
13     constructor() {
14     super('notedel', 'moderation', []);
15     }
16    
17     async run(client: DiscordClient, msg: Message | CommandInteraction, options: CommandOptions | InteractionOptions) {
18     if (!options.isInteraction && typeof options.args[0] === 'undefined') {
19     await msg.reply({
20     embeds: [
21     new MessageEmbed()
22     .setColor('#f14a60')
23     .setDescription(`This command requires at least one argument.`)
24     ]
25     });
26    
27     return;
28     }
29    
30     let id: string;
31    
32     if (options.isInteraction) {
33 rakin 334 id = await <string> options.options.getString('id');
34 rakin 51 }
35     else {
36     id = await options.args[0];
37     }
38    
39 rakin 86 const note = await Note.findOne({
40 rakin 334 guild_id: msg.guild!.id,
41     _id: id
42 rakin 86 });
43 rakin 51
44 rakin 86 if (!note) {
45     await msg.reply(`${await fetchEmojiStr('error')} Invalid note ID.`);
46     return;
47     }
48 rakin 51
49 rakin 334 await note.delete();
50 rakin 51
51 rakin 86 await msg.reply({
52     embeds: [
53     new MessageEmbed({
54     description: `${await fetchEmojiStr('check')} Note deleted.`
55     })
56     ]
57 rakin 51 });
58     }
59     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26