Commands dont get executed somehow

const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!')
.addBooleanOption(option =>
option.setName('hide')
.setDescription('Wherever the respond is hidden or not')
.setRequired(true)),
async execute(interaction) {
let hide = interaction.options.getBoolean('hide');
await interaction.reply({content: `API Latency is ${Math.round(interaction.client.ws.ping)}ms`, ephemeral: hide});
},
};
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!')
.addBooleanOption(option =>
option.setName('hide')
.setDescription('Wherever the respond is hidden or not')
.setRequired(true)),
async execute(interaction) {
let hide = interaction.options.getBoolean('hide');
await interaction.reply({content: `API Latency is ${Math.round(interaction.client.ws.ping)}ms`, ephemeral: hide});
},
};
this is my /ping command. It gets registered but it doesn't get executed when i do /ping hide:true in my discord.
11 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Basgamer999
Basgamer999OP2y ago
*14.7.1 node:18.13.0 *no errors that makes it wierd
const { REST } = require('@discordjs/rest')
const { Routes } = require('discord-api-types/v10')
const fs = require("fs");

module.exports = (client) => {
client.handleCommands = async () => {
const commandFolders = fs.readdirSync("./src/commands");
for (const folder of commandFolders) {
const commandFiles = fs
.readdirSync(`./src/commands/${folder}`)
.filter((file) => file.endsWith(".js"));

const { commands, commandArray } = client;
for (const file of commandFiles) {
const command = require(`../../commands/${folder}/${file}`);
commands.set(command.data.name, command);
commandArray.push(command.data.toJSON());
}
}

const clientId = '1062792579780976740';
const guildId = '1062791717054591057';
const rest = new REST({ version: '9' }).setToken(process.env.token)
try {
console.log('started refreshing application (/) commands');

await rest.put(Routes.applicationGuildCommands(clientId,guildId), {
body: client.commandArray,
});

console.log('All slash commands have been registered without errors')
} catch (error) {
console.error(error)
}
};
};
const { REST } = require('@discordjs/rest')
const { Routes } = require('discord-api-types/v10')
const fs = require("fs");

module.exports = (client) => {
client.handleCommands = async () => {
const commandFolders = fs.readdirSync("./src/commands");
for (const folder of commandFolders) {
const commandFiles = fs
.readdirSync(`./src/commands/${folder}`)
.filter((file) => file.endsWith(".js"));

const { commands, commandArray } = client;
for (const file of commandFiles) {
const command = require(`../../commands/${folder}/${file}`);
commands.set(command.data.name, command);
commandArray.push(command.data.toJSON());
}
}

const clientId = '1062792579780976740';
const guildId = '1062791717054591057';
const rest = new REST({ version: '9' }).setToken(process.env.token)
try {
console.log('started refreshing application (/) commands');

await rest.put(Routes.applicationGuildCommands(clientId,guildId), {
body: client.commandArray,
});

console.log('All slash commands have been registered without errors')
} catch (error) {
console.error(error)
}
};
};
handle command file * The commands get registered but not executed
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Basgamer999
Basgamer999OP2y ago
thats the only part that handles commands the other files are responsible for other parts to work
const fs = require("fs");

module.exports = (client) => {
client.handleEvents = async () => {
const eventFolders = fs.readdirSync(`./src/events`);
for (const folder of eventFolders) {
const eventFiles = fs
.readdirSync(`./src/events/${folder}`)
.filter((file) => file.endsWith("js"));
switch (folder) {
case "client":
for (const file of eventFiles) {
const event = require(`../../events/${folder}/${file}`);
if (event.once) client.once(event.name, (...args) => event.execute(...args, client))
else client.on(event.name, (...args) => event.execute(...args, client));
}
break;

default:
break;
}
}
};
};
const fs = require("fs");

module.exports = (client) => {
client.handleEvents = async () => {
const eventFolders = fs.readdirSync(`./src/events`);
for (const folder of eventFolders) {
const eventFiles = fs
.readdirSync(`./src/events/${folder}`)
.filter((file) => file.endsWith("js"));
switch (folder) {
case "client":
for (const file of eventFiles) {
const event = require(`../../events/${folder}/${file}`);
if (event.once) client.once(event.name, (...args) => event.execute(...args, client))
else client.on(event.name, (...args) => event.execute(...args, client));
}
break;

default:
break;
}
}
};
};
like this one for my events
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Basgamer999
Basgamer999OP2y ago
o i might have deleted that oops
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Basgamer999
Basgamer999OP2y ago
that makes sense thanks
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Basgamer999
Basgamer999OP2y ago
yep now it works thank you ❤️
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server