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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 55 - (show annotations)
Mon Jul 29 17:28:24 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: application/typescript
File size: 1721 byte(s)
Added -ballot command
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
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 const allowed = await client.auth.verify(interaction.member! as GuildMember, commandName);
20
21 if (command && command.supportsInteractions) {
22 if (!allowed) {
23 await interaction.reply({
24 embeds: [
25 new MessageEmbed()
26 .setColor('#f14a60')
27 .setDescription(":x: You don't have permission to run this command.")
28 ],
29 ephemeral: true
30 });
31
32 return;
33 }
34
35 const options = {
36 cmdName: commandName,
37 options: interaction.options,
38 isInteraction: true
39 } as InteractionOptions;
40
41 if (!await client.cooldown.start(interaction, options))
42 return;
43
44 await command.run(client, interaction, options);
45 }
46 }
47 }
48 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26