1 |
rakin |
51 |
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 |
|
|
|
12 |
|
|
export default class NotedelCommand extends BaseCommand { |
13 |
|
|
supportsInteractions: boolean = true; |
14 |
|
|
|
15 |
|
|
constructor() { |
16 |
|
|
super('notedel', 'moderation', []); |
17 |
|
|
} |
18 |
|
|
|
19 |
|
|
async run(client: DiscordClient, msg: Message | CommandInteraction, options: CommandOptions | InteractionOptions) { |
20 |
|
|
if (!options.isInteraction && typeof options.args[0] === 'undefined') { |
21 |
|
|
await msg.reply({ |
22 |
|
|
embeds: [ |
23 |
|
|
new MessageEmbed() |
24 |
|
|
.setColor('#f14a60') |
25 |
|
|
.setDescription(`This command requires at least one argument.`) |
26 |
|
|
] |
27 |
|
|
}); |
28 |
|
|
|
29 |
|
|
return; |
30 |
|
|
} |
31 |
|
|
|
32 |
|
|
let id: string; |
33 |
|
|
|
34 |
|
|
if (options.isInteraction) { |
35 |
|
|
id = await <string> options.options.getNumber('id')?.toString(); |
36 |
|
|
} |
37 |
|
|
else { |
38 |
|
|
id = await options.args[0]; |
39 |
|
|
} |
40 |
|
|
|
41 |
|
|
await client.db.get("SELECT * FROM notes WHERE id = ? AND guild_id = ?", [id, msg.guild!.id], async (err: any, data: any) => { |
42 |
|
|
if (err) { |
43 |
|
|
console.log(err); |
44 |
|
|
} |
45 |
|
|
|
46 |
|
|
if (data === undefined) { |
47 |
|
|
await msg.reply({ |
48 |
|
|
embeds: [ |
49 |
|
|
new MessageEmbed() |
50 |
|
|
.setColor('#f14a60') |
51 |
|
|
.setDescription('No note found') |
52 |
|
|
] |
53 |
|
|
}); |
54 |
|
|
|
55 |
|
|
return; |
56 |
|
|
} |
57 |
|
|
|
58 |
|
|
await client.db.get('DELETE FROM notes WHERE id = ? AND guild_id = ?', [id, msg.guild!.id], async (err: any) => { |
59 |
|
|
if (err) { |
60 |
|
|
console.log(err); |
61 |
|
|
} |
62 |
|
|
|
63 |
|
|
|
64 |
|
|
await History.create(data.user_id, msg.guild!, 'notedel', msg.member?.user.id!, '', async (data2: any) => { |
65 |
|
|
await msg.reply({ |
66 |
|
|
embeds: [ |
67 |
|
|
new MessageEmbed() |
68 |
|
|
.setDescription('The note has been deleted') |
69 |
|
|
] |
70 |
|
|
}); |
71 |
|
|
}); |
72 |
|
|
}); |
73 |
|
|
}); |
74 |
|
|
} |
75 |
|
|
} |