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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 54 - (show annotations)
Mon Jul 29 17:28:24 2024 UTC (8 months, 2 weeks ago) by rakin
Original Path: trunk/src/events/interaction/InteractionCreate.ts
File MIME type: application/typescript
File size: 1578 byte(s)
Added -emoji command and cooldown support
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 await command.run(client, interaction, {
36 cmdName: commandName,
37 options: interaction.options,
38 isInteraction: true
39 } as InteractionOptions);
40 }
41 }
42 }
43 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26