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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 337 - (hide annotations)
Mon Jul 29 17:29:37 2024 UTC (8 months, 2 weeks ago) by rakin
File MIME type: application/typescript
File size: 2355 byte(s)
refactor(models): punishment appeal
1 rakin 81 import { BanOptions, CommandInteraction, EmojiIdentifierResolvable, GuildMember, Interaction, Message, TextChannel, User } from 'discord.js';
2     import BaseCommand from '../../utils/structures/BaseCommand';
3     import DiscordClient from '../../client/Client';
4     import InteractionOptions from '../../types/InteractionOptions';
5     import { Modal, ModalSubmitInteraction, showModal, TextInputComponent } from 'discord-modals';
6     import PunishmentAppeal from '../../models/PunishmentAppeal';
7    
8     export default class AppealCommand extends BaseCommand {
9     supportsInteractions: boolean = true;
10     supportsLegacy = false;
11    
12     constructor() {
13     super('appeal', 'moderation', []);
14     }
15    
16     async modalSubmit(client: DiscordClient, interaction: ModalSubmitInteraction) {
17     if (interaction.customId === 'appeal-modal') {
18     const content = interaction.getTextInputValue('appeal-content');
19    
20     await PunishmentAppeal.create({
21     user_id: interaction.member.id,
22     guild_id: interaction.guild!.id,
23 rakin 337 content,
24     createdAt: new Date()
25 rakin 81 });
26    
27     await interaction.reply({
28     content: 'Your message was submitted successfully!',
29     ephemeral: true
30     });
31     }
32     }
33    
34     async run(client: DiscordClient, interaction: CommandInteraction, options: InteractionOptions) {
35     const existingData = await PunishmentAppeal.findOne({
36 rakin 337 user_id: interaction.member!.user.id,
37     guild_id: interaction.guild!.id
38 rakin 81 });
39    
40     if (!existingData) {
41     const modal = new Modal()
42     .setCustomId('appeal-modal')
43     .setTitle('Punishment Appeal Contact')
44     .addComponents(
45     new TextInputComponent()
46     .setCustomId('appeal-content')
47     .setLabel('Your message')
48     .setStyle('LONG')
49     .setMinLength(4)
50     .setRequired(true),
51     );
52    
53     await showModal(modal, {
54     client,
55     interaction,
56     });
57     }
58     else {
59     await interaction.reply({
60     content: "You already submitted a punishment appeal.",
61     ephemeral: true
62     });
63     }
64     }
65     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26