const { REST } = require('@discordjs/rest')
const { Routes } = require('discord-api-types/v9');
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, commadArray } = client;
for (const file of commandFiles) {
const command = require(`../../commands/${folder}/${file}`);
commands.set(command.data.name, command);
commandArray.push(command.data.toJSON());
console.log(`Command: ${command.data.name} has passed through the handler.`)
}
}
const clientId = 'x';
const guildId = 'y';
const rest = new REST({ version: '9' }).setToken(process.env.token);
try {
console.log('Started refreshing appication (/) commands.');
await rest.put(
Routes.applicationCommands(clientId, guildId),
{ body: client.commandArray },
);
console.log('Succesfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
}
};```
`commandArray.push(command.data.toJSON());
^
ReferenceError: commandArray is not defined`
#commandArray not defined
8 messages · Page 1 of 1 (latest)
• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.
js issue
nvm im brain dead