/[sudobot]/trunk/src/events/interaction/InteractionCreate.ts
ViewVC logotype

Annotation of /trunk/src/events/interaction/InteractionCreate.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 58 - (hide annotations)
Mon Jul 29 17:28:25 2024 UTC (8 months, 2 weeks ago) by rakin
File MIME type: application/typescript
File size: 1722 byte(s)
Added debug info support and startup manager
1 rakin 51 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    
7     export default class InteractionCreateEvent extends BaseEvent {
8     constructor() {
9     super('interactionCreate');
10     }
11    
12     async run(client: DiscordClient, interaction: Interaction) {
13     if (interaction.isCommand()) {
14     await client.setMessage(interaction);
15    
16     const { commandName } = interaction;
17    
18     const command = await client.commands.get(commandName);
19    
20     if (command && command.supportsInteractions) {
21 rakin 58 const allowed = await client.auth.verify(interaction.member! as GuildMember, command);
22    
23 rakin 51 if (!allowed) {
24     await interaction.reply({
25     embeds: [
26     new MessageEmbed()
27     .setColor('#f14a60')
28     .setDescription(":x: You don't have permission to run this command.")
29     ],
30     ephemeral: true
31     });
32    
33     return;
34     }
35    
36 rakin 55 const options = {
37 rakin 51 cmdName: commandName,
38     options: interaction.options,
39     isInteraction: true
40 rakin 55 } as InteractionOptions;
41    
42     if (!await client.cooldown.start(interaction, options))
43     return;
44    
45     await command.run(client, interaction, options);
46 rakin 51 }
47     }
48     }
49     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26