1 |
rakinar2 |
577 |
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 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 History from '../../automod/History'; |
10 |
|
|
import { fetchEmoji } from '../../utils/Emoji'; |
11 |
|
|
import { Modal, ModalSubmitInteraction, showModal, TextInputComponent } from 'discord-modals'; |
12 |
|
|
import PunishmentAppeal from '../../models/PunishmentAppeal'; |
13 |
|
|
|
14 |
|
|
export default class AppealCommand extends BaseCommand { |
15 |
|
|
supportsInteractions: boolean = true; |
16 |
|
|
supportsLegacy = false; |
17 |
|
|
|
18 |
|
|
constructor() { |
19 |
|
|
super('appeal', 'moderation', []); |
20 |
|
|
} |
21 |
|
|
|
22 |
|
|
async modalSubmit(client: DiscordClient, interaction: ModalSubmitInteraction) { |
23 |
|
|
if (interaction.customId === 'appeal-modal') { |
24 |
|
|
const content = interaction.getTextInputValue('appeal-content'); |
25 |
|
|
|
26 |
|
|
await PunishmentAppeal.create({ |
27 |
|
|
user_id: interaction.member.id, |
28 |
|
|
guild_id: interaction.guild!.id, |
29 |
|
|
content |
30 |
|
|
}); |
31 |
|
|
|
32 |
|
|
await interaction.reply({ |
33 |
|
|
content: 'Your message was submitted successfully!', |
34 |
|
|
ephemeral: true |
35 |
|
|
}); |
36 |
|
|
} |
37 |
|
|
} |
38 |
|
|
|
39 |
|
|
async run(client: DiscordClient, interaction: CommandInteraction, options: InteractionOptions) { |
40 |
|
|
const existingData = await PunishmentAppeal.findOne({ |
41 |
|
|
where: { |
42 |
|
|
user_id: interaction.member!.user.id, |
43 |
|
|
guild_id: interaction.guild!.id |
44 |
|
|
} |
45 |
|
|
}); |
46 |
|
|
|
47 |
|
|
if (!existingData) { |
48 |
|
|
const modal = new Modal() |
49 |
|
|
.setCustomId('appeal-modal') |
50 |
|
|
.setTitle('Punishment Appeal Contact') |
51 |
|
|
.addComponents( |
52 |
|
|
new TextInputComponent() |
53 |
|
|
.setCustomId('appeal-content') |
54 |
|
|
.setLabel('Your message') |
55 |
|
|
.setStyle('LONG') |
56 |
|
|
.setMinLength(4) |
57 |
|
|
.setRequired(true), |
58 |
|
|
); |
59 |
|
|
|
60 |
|
|
await showModal(modal, { |
61 |
|
|
client, |
62 |
|
|
interaction, |
63 |
|
|
}); |
64 |
|
|
} |
65 |
|
|
else { |
66 |
|
|
await interaction.reply({ |
67 |
|
|
content: "You already submitted a punishment appeal.", |
68 |
|
|
ephemeral: true |
69 |
|
|
}); |
70 |
|
|
} |
71 |
|
|
} |
72 |
|
|
} |