TypeError: Cannot read properties of undefined (reading 'name') #10036
-
Which package is this bug report for?discord.js Issue descriptionso I am currently making a bot for my server, nothing was wrong with the handlecommand.js file until I made the ping.js command, and everytime I try running the bot I get the same error. I can't find any way to fix this Code sampleconst { 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, commandArray } = 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}`)
}
}
const clientId = '994413854752772136';
const rest = new REST({ version: '9' }).setToken(process.env.token);
try {
console.log('Started refreshing application (/) commands.');
await rest.put(Routes.applicationCommands(clientId), {
body: client.commandArray,
});
console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
};
};Versions-Node.js v20.10.0 Which partials do you have configured?No Partials Which gateway intents are you subscribing to?Guilds, GuildMembers, GuildModeration, GuildEmojisAndStickers, GuildIntegrations, GuildWebhooks, GuildInvites, GuildVoiceStates, GuildPresences, GuildMessages, GuildMessageReactions, GuildMessageTyping, DirectMessages, DirectMessageReactions, DirectMessageTyping, MessageContent, GuildScheduledEvents, AutoModerationConfiguration, AutoModerationExecution |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
one of your commands exports no object with a |
Beta Was this translation helpful? Give feedback.
one of your commands exports no object with a
.datakey where this code loading and running it expects one