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