/[sudobot]/trunk/src/events/modal/ModalSubmit.ts
ViewVC logotype

Contents of /trunk/src/events/modal/ModalSubmit.ts

Parent Directory Parent Directory | Revision Log Revision Log


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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26