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 |
|
|
console.log('inside'); |
14 |
|
|
|
15 |
|
|
if (interaction.isCommand()) { |
16 |
|
|
await client.setMessage(interaction); |
17 |
|
|
|
18 |
|
|
const { commandName } = interaction; |
19 |
|
|
|
20 |
|
|
const command = await client.commands.get(commandName); |
21 |
|
|
const allowed = await client.auth.verify(interaction.member! as GuildMember, commandName); |
22 |
|
|
|
23 |
|
|
if (command && command.supportsInteractions) { |
24 |
|
|
if (!allowed) { |
25 |
|
|
await interaction.reply({ |
26 |
|
|
embeds: [ |
27 |
|
|
new MessageEmbed() |
28 |
|
|
.setColor('#f14a60') |
29 |
|
|
.setDescription(":x: You don't have permission to run this command.") |
30 |
|
|
], |
31 |
|
|
ephemeral: true |
32 |
|
|
}); |
33 |
|
|
|
34 |
|
|
return; |
35 |
|
|
} |
36 |
|
|
|
37 |
|
|
await command.run(client, interaction, { |
38 |
|
|
cmdName: commandName, |
39 |
|
|
options: interaction.options, |
40 |
|
|
isInteraction: true |
41 |
|
|
} as InteractionOptions); |
42 |
|
|
} |
43 |
|
|
} |
44 |
|
|
} |
45 |
|
|
} |