Skip to content

Commit

Permalink
Fix help command in guild
Browse files Browse the repository at this point in the history
  • Loading branch information
KwikKill committed Sep 9, 2024
1 parent b5fd4ab commit e0c00b4
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions commands/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,16 @@ module.exports = {
async autocomplete(client, interaction) {
const focusedValue = interaction.options.getFocused();
let cmds = [];
client.commands.filter(cmd => client.canRunCommande(undefined, cmd, interaction) && cmd.name.startsWith(focusedValue) && (cmd.place === "guild" || cmd.place === "both") && (cmd.serverid === undefined || cmd.serverid?.includes(interaction.guild.id))).forEach(cmd => {
cmds.push({ name: cmd.name, value: cmd.name });
});
// if the interaction is not in a guild, we return only the global commands
if (interaction.guild === null) {
client.commands.filter(cmd => cmd.name.startsWith(focusedValue) && (cmd.place === "dm" || cmd.place === "both")).forEach(cmd => {
cmds.push({ name: cmd.name, value: cmd.name });
});
} else {
client.commands.filter(cmd => client.canRunCommande(undefined, cmd, interaction) && cmd.name.startsWith(focusedValue) && (cmd.place === "guild" || cmd.place === "both") && (cmd.serverid === undefined || cmd.serverid?.includes(interaction.guild.id))).forEach(cmd => {
cmds.push({ name: cmd.name, value: cmd.name });
});
}
if (cmds.length > 15) {
cmds = cmds.slice(0, 15);
}
Expand Down

0 comments on commit e0c00b4

Please sign in to comment.