/[sudobot]/branches/2.x/src/events/modal/ModalSubmit.ts
ViewVC logotype

Contents of /branches/2.x/src/events/modal/ModalSubmit.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 577 - (show annotations)
Mon Jul 29 18:52:37 2024 UTC (8 months ago) by rakinar2
File MIME type: application/typescript
File size: 1398 byte(s)
chore: add old version archive branches (2.x to 9.x-dev)
1 import BaseEvent from '../../utils/structures/BaseEvent';
2 import { GuildMember, Interaction, Message, MessageEmbed } from 'discord.js';
3 import DiscordClient from '../../client/Client';
4 import CommandOptions from '../../types/CommandOptions';
5 import InteractionOptions from '../../types/InteractionOptions';
6 import AutoCompleteOptions from '../../types/AutoCompleteOptions';
7 import { ModalSubmitInteraction } from 'discord-modals';
8
9 export default class ModalSubmitEvent extends BaseEvent {
10 constructor() {
11 super('modalSubmit');
12 }
13
14 async run(client: DiscordClient, interaction: ModalSubmitInteraction) {
15 if (!interaction.guild || !interaction.channel || interaction.channel.type === 'DM') {
16 if (interaction.isRepliable())
17 await interaction.reply({
18 content: 'You cannot use this bot on DMs.',
19 ephemeral: true
20 });
21
22 return;
23 }
24
25 if ((global as any).lastCommand) {
26 const cmd = client.commands.get((global as any).lastCommand);
27
28 if (cmd && cmd.supportsInteractions) {
29 const allowed = await client.auth.verify(interaction.member! as GuildMember, cmd);
30
31 if (!allowed) {
32 return;
33 }
34
35 await cmd.modalSubmit(client, interaction);
36 }
37 }
38 }
39 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26