Skip to content

Commit

Permalink
fix: InteractionCreate
Browse files Browse the repository at this point in the history
Fixed checking guild only slash commands.
  • Loading branch information
Tolga1452 committed Sep 30, 2022
1 parent a7e7f9c commit 3b797c1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions shard.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,21 @@ client
.on('interactionCreate', async interaction => {
if (interaction.isCommand()) {
let name = interaction.commandName.split(' ')[0];
let command = interactions.commands.get(name);
let guild = interaction.commandGuildId;
let command;

if (guild) command = interactions.guildCommands[guild].get(name);
else command = interactions.commands.get(name);

if (command) command.execute(interaction, client);
else logger.error(`[Shard ${shard}] [Events/InteractionCreate/Command] ${name} command could not found`);
} else if (interaction.isAutocomplete()) {
let name = interaction.commandName.split(' ')[0];
let command = interactions.commands.get(name);
let guild = interaction.commandGuildId;
let command;

if (guild) command = interactions.guildCommands[guild].get(name);
else command = interactions.commands.get(name);

if (command) command.autocomplete(interaction, client);
else logger.error(`[Shard ${shard}] [Events/InteractionCreate/Autocomplete] ${name} command could not found`);
Expand Down

0 comments on commit 3b797c1

Please sign in to comment.