1 |
import { BanOptions, CommandInteraction, Guild, GuildMember, Interaction, Message, User } from 'discord.js'; |
import { CommandInteraction, Message } from 'discord.js'; |
2 |
import BaseCommand from '../../utils/structures/BaseCommand'; |
import BaseCommand from '../../utils/structures/BaseCommand'; |
3 |
import DiscordClient from '../../client/Client'; |
import DiscordClient from '../../client/Client'; |
4 |
import CommandOptions from '../../types/CommandOptions'; |
import CommandOptions from '../../types/CommandOptions'; |
5 |
import InteractionOptions from '../../types/InteractionOptions'; |
import InteractionOptions from '../../types/InteractionOptions'; |
6 |
import MessageEmbed from '../../client/MessageEmbed'; |
import MessageEmbed from '../../client/MessageEmbed'; |
7 |
import getUser from '../../utils/getUser'; |
import Note from '../../models/Note'; |
8 |
import History from '../../automod/History'; |
import { fetchEmojiStr } from '../../utils/Emoji'; |
|
import getMember from '../../utils/getMember'; |
|
|
import ms from 'ms'; |
|
9 |
|
|
10 |
export default class NotedelCommand extends BaseCommand { |
export default class NotedelCommand extends BaseCommand { |
11 |
supportsInteractions: boolean = true; |
supportsInteractions: boolean = true; |
30 |
let id: string; |
let id: string; |
31 |
|
|
32 |
if (options.isInteraction) { |
if (options.isInteraction) { |
33 |
id = await <string> options.options.getNumber('id')?.toString(); |
id = await <string> options.options.getString('id'); |
34 |
} |
} |
35 |
else { |
else { |
36 |
id = await options.args[0]; |
id = await options.args[0]; |
37 |
} |
} |
38 |
|
|
39 |
await client.db.get("SELECT * FROM notes WHERE id = ? AND guild_id = ?", [id, msg.guild!.id], async (err: any, data: any) => { |
const note = await Note.findOne({ |
40 |
if (err) { |
guild_id: msg.guild!.id, |
41 |
console.log(err); |
_id: id |
42 |
} |
}); |
43 |
|
|
44 |
if (data === undefined) { |
if (!note) { |
45 |
await msg.reply({ |
await msg.reply(`${await fetchEmojiStr('error')} Invalid note ID.`); |
46 |
embeds: [ |
return; |
47 |
new MessageEmbed() |
} |
48 |
.setColor('#f14a60') |
|
49 |
.setDescription('No note found') |
await note.delete(); |
50 |
] |
|
51 |
}); |
await msg.reply({ |
52 |
|
embeds: [ |
53 |
return; |
new MessageEmbed({ |
54 |
} |
description: `${await fetchEmojiStr('check')} Note deleted.` |
55 |
|
}) |
56 |
await client.db.get('DELETE FROM notes WHERE id = ? AND guild_id = ?', [id, msg.guild!.id], async (err: any) => { |
] |
|
if (err) { |
|
|
console.log(err); |
|
|
} |
|
|
|
|
|
|
|
|
await History.create(data.user_id, msg.guild!, 'notedel', msg.member?.user.id!, '', async (data2: any) => { |
|
|
await msg.reply({ |
|
|
embeds: [ |
|
|
new MessageEmbed() |
|
|
.setDescription('The note has been deleted') |
|
|
] |
|
|
}); |
|
|
}); |
|
|
}); |
|
57 |
}); |
}); |
58 |
} |
} |
59 |
} |
} |