1 |
import { BanOptions, CommandInteraction, Guild, GuildMember, Interaction, Message, User } 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 getUser from '../../utils/getUser'; |
8 |
import getMember from '../../utils/getMember'; |
9 |
import ms from 'ms'; |
10 |
import Note from '../../models/Note'; |
11 |
import { fetchEmojiStr } from '../../utils/Emoji'; |
12 |
|
13 |
export default class NotedelCommand extends BaseCommand { |
14 |
supportsInteractions: boolean = true; |
15 |
|
16 |
constructor() { |
17 |
super('notedel', 'moderation', []); |
18 |
} |
19 |
|
20 |
async run(client: DiscordClient, msg: Message | CommandInteraction, options: CommandOptions | InteractionOptions) { |
21 |
if (!options.isInteraction && typeof options.args[0] === 'undefined') { |
22 |
await msg.reply({ |
23 |
embeds: [ |
24 |
new MessageEmbed() |
25 |
.setColor('#f14a60') |
26 |
.setDescription(`This command requires at least one argument.`) |
27 |
] |
28 |
}); |
29 |
|
30 |
return; |
31 |
} |
32 |
|
33 |
let id: string; |
34 |
|
35 |
if (options.isInteraction) { |
36 |
id = await <string> options.options.getString('id'); |
37 |
} |
38 |
else { |
39 |
id = await options.args[0]; |
40 |
} |
41 |
|
42 |
const note = await Note.findOne({ |
43 |
guild_id: msg.guild!.id, |
44 |
_id: id |
45 |
}); |
46 |
|
47 |
if (!note) { |
48 |
await msg.reply(`${await fetchEmojiStr('error')} Invalid note ID.`); |
49 |
return; |
50 |
} |
51 |
|
52 |
await note.delete(); |
53 |
|
54 |
await msg.reply({ |
55 |
embeds: [ |
56 |
new MessageEmbed({ |
57 |
description: `${await fetchEmojiStr('check')} Note deleted.` |
58 |
}) |
59 |
] |
60 |
}); |
61 |
} |
62 |
} |