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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 341 - (hide annotations)
Mon Jul 29 17:29:38 2024 UTC (8 months, 2 weeks ago) by rakin
File MIME type: application/typescript
File size: 1949 byte(s)
refactor: removing using the old history manager
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 getMember from '../../utils/getMember';
9     import ms from 'ms';
10 rakin 86 import Note from '../../models/Note';
11     import { fetchEmojiStr } from '../../utils/Emoji';
12 rakin 51
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 rakin 334 id = await <string> options.options.getString('id');
37 rakin 51 }
38     else {
39     id = await options.args[0];
40     }
41    
42 rakin 86 const note = await Note.findOne({
43 rakin 334 guild_id: msg.guild!.id,
44     _id: id
45 rakin 86 });
46 rakin 51
47 rakin 86 if (!note) {
48     await msg.reply(`${await fetchEmojiStr('error')} Invalid note ID.`);
49     return;
50     }
51 rakin 51
52 rakin 334 await note.delete();
53 rakin 51
54 rakin 86 await msg.reply({
55     embeds: [
56     new MessageEmbed({
57     description: `${await fetchEmojiStr('check')} Note deleted.`
58     })
59     ]
60 rakin 51 });
61     }
62     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26