1 |
import BaseEvent from '../../utils/structures/BaseEvent'; |
import BaseEvent from '../../utils/structures/BaseEvent'; |
2 |
import { GuildMember, Interaction, Message, MessageEmbed } from 'discord.js'; |
import { GuildMember, Interaction, MessageEmbed } from 'discord.js'; |
3 |
import DiscordClient from '../../client/Client'; |
import DiscordClient from '../../client/Client'; |
|
import CommandOptions from '../../types/CommandOptions'; |
|
4 |
import InteractionOptions from '../../types/InteractionOptions'; |
import InteractionOptions from '../../types/InteractionOptions'; |
5 |
import AutoCompleteOptions from '../../types/AutoCompleteOptions'; |
import AutoCompleteOptions from '../../types/AutoCompleteOptions'; |
6 |
|
|
20 |
return; |
return; |
21 |
} |
} |
22 |
|
|
23 |
if (interaction.isCommand()) { |
if (interaction.isCommand() || interaction.isContextMenu()) { |
24 |
await client.setMessage(interaction); |
await client.setMessage(interaction); |
25 |
|
|
26 |
const { commandName } = interaction; |
const { commandName } = interaction; |
27 |
|
|
28 |
const command = await client.commands.get(commandName); |
const command = await client.commands.get(commandName); |
29 |
|
|
30 |
if (command && command.supportsInteractions) { |
if (command && ((interaction.isCommand() && command.supportsInteractions) || (interaction.isContextMenu() && command.supportsContextMenu))) { |
31 |
const allowed = await client.auth.verify(interaction.member! as GuildMember, command); |
const allowed = await client.auth.verify(interaction.member! as GuildMember, command); |
32 |
|
|
33 |
if (!allowed) { |
if (!allowed) { |
49 |
isInteraction: true |
isInteraction: true |
50 |
} as InteractionOptions; |
} as InteractionOptions; |
51 |
|
|
52 |
if (!await client.cooldown.start(interaction, options)) |
await command.execute(client, interaction, options); |
|
return; |
|
|
|
|
|
await command.run(client, interaction, options); |
|
53 |
(global as any).lastCommand = commandName; |
(global as any).lastCommand = commandName; |
54 |
} |
} |
55 |
} |
} |
67 |
return; |
return; |
68 |
} |
} |
69 |
|
|
70 |
|
if (!(await command.perms(client, interaction))) { |
71 |
|
return; |
72 |
|
} |
73 |
|
|
74 |
const options = { |
const options = { |
75 |
cmdName: commandName, |
cmdName: commandName, |
76 |
options: interaction.options, |
options: interaction.options, |
97 |
if (!allowed) { |
if (!allowed) { |
98 |
return; |
return; |
99 |
} |
} |
100 |
|
|
101 |
|
if (!(await command.perms(client, interaction))) { |
102 |
|
return; |
103 |
|
} |
104 |
|
|
105 |
await command.default(client, interaction); |
await command.default(client, interaction); |
106 |
} |
} |