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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 344 - (show 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 import { CommandInteraction, Message } from 'discord.js';
2 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 import Note from '../../models/Note';
8 import { fetchEmojiStr } from '../../utils/Emoji';
9
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 id = await <string> options.options.getString('id');
34 }
35 else {
36 id = await options.args[0];
37 }
38
39 const note = await Note.findOne({
40 guild_id: msg.guild!.id,
41 _id: id
42 });
43
44 if (!note) {
45 await msg.reply(`${await fetchEmojiStr('error')} Invalid note ID.`);
46 return;
47 }
48
49 await note.delete();
50
51 await msg.reply({
52 embeds: [
53 new MessageEmbed({
54 description: `${await fetchEmojiStr('check')} Note deleted.`
55 })
56 ]
57 });
58 }
59 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26