3 |
import DiscordClient from '../../client/Client'; |
import DiscordClient from '../../client/Client'; |
4 |
import CommandOptions from '../../types/CommandOptions'; |
import CommandOptions from '../../types/CommandOptions'; |
5 |
import InteractionOptions from '../../types/InteractionOptions'; |
import InteractionOptions from '../../types/InteractionOptions'; |
6 |
|
import AutoCompleteOptions from '../../types/AutoCompleteOptions'; |
7 |
|
|
8 |
export default class InteractionCreateEvent extends BaseEvent { |
export default class InteractionCreateEvent extends BaseEvent { |
9 |
constructor() { |
constructor() { |
46 |
await command.run(client, interaction, options); |
await command.run(client, interaction, options); |
47 |
} |
} |
48 |
} |
} |
49 |
|
else if (interaction.isAutocomplete()) { |
50 |
|
await client.setMessage(interaction); |
51 |
|
|
52 |
|
const { commandName } = interaction; |
53 |
|
|
54 |
|
const command = await client.commands.get(commandName); |
55 |
|
|
56 |
|
if (command && command.supportsInteractions) { |
57 |
|
const allowed = await client.auth.verify(interaction.member! as GuildMember, command); |
58 |
|
|
59 |
|
if (!allowed) { |
60 |
|
return; |
61 |
|
} |
62 |
|
|
63 |
|
const options = { |
64 |
|
cmdName: commandName, |
65 |
|
options: interaction.options, |
66 |
|
isInteraction: true, |
67 |
|
optionName: interaction.options.getFocused(true).name, |
68 |
|
query: interaction.options.getFocused(true).value.toString() |
69 |
|
} as AutoCompleteOptions; |
70 |
|
|
71 |
|
await command.autoComplete(client, interaction, options); |
72 |
|
} |
73 |
|
} |
74 |
} |
} |
75 |
} |
} |