error on handelcomands though i didnt wrote anything there

client.commands.set(command.data.name, command); ^ TypeError: Cannot read properties of undefined (reading 'name')
5 Replies
d.js toolkit
d.js toolkit11mo ago
- 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. - Issue solved? Press the button!
kjuaeldcanarion
kjuaeldcanarion11mo ago
PS C:\Users\kjuan\Desktop\v14 slash> node .
C:\Users\kjuan\Desktop\v14 slash\src\functions\handelCommands.js:15
client.commands.set(command.data.name, command);
^

TypeError: Cannot read properties of undefined (reading 'name')
at client.handleCommands (C:\Users\kjuan\Desktop\v14 slash\src\functions\handelCommands.js:15:50)
at C:\Users\kjuan\Desktop\v14 slash\src\index.js:21:12
at Object.<anonymous> (C:\Users\kjuan\Desktop\v14 slash\src\index.js:23:3)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47

Node.js v18.16.1
PS C:\Users\kjuan\Desktop\v14 slash>
PS C:\Users\kjuan\Desktop\v14 slash> node .
C:\Users\kjuan\Desktop\v14 slash\src\functions\handelCommands.js:15
client.commands.set(command.data.name, command);
^

TypeError: Cannot read properties of undefined (reading 'name')
at client.handleCommands (C:\Users\kjuan\Desktop\v14 slash\src\functions\handelCommands.js:15:50)
at C:\Users\kjuan\Desktop\v14 slash\src\index.js:21:12
at Object.<anonymous> (C:\Users\kjuan\Desktop\v14 slash\src\index.js:23:3)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47

Node.js v18.16.1
PS C:\Users\kjuan\Desktop\v14 slash>
this is the full error
const { REST } = require("@discordjs/rest");
const { Routes } = require('discord-api-types/v9');
const fs = require('fs');

const clientId = '1130941137213997209';
const guildId = 'YOUR SERVERS nod';

module.exports = (client) => {
client.handleCommands = async (commandFolders, path) => {
client.commandArray = [];
for (folder of commandFolders) {
const commandFiles = fs.readdirSync(`${path}/${folder}`).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`../commands/${folder}/${file}`);
client.commands.set(command.data.name, command);
client.commandArray.push(command.data.toJSON());
}
}

const rest = new REST({
version: '9'
}).setToken(process.env.token);

(async () => {
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);
}
})();
};
};
const { REST } = require("@discordjs/rest");
const { Routes } = require('discord-api-types/v9');
const fs = require('fs');

const clientId = '1130941137213997209';
const guildId = 'YOUR SERVERS nod';

module.exports = (client) => {
client.handleCommands = async (commandFolders, path) => {
client.commandArray = [];
for (folder of commandFolders) {
const commandFiles = fs.readdirSync(`${path}/${folder}`).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`../commands/${folder}/${file}`);
client.commands.set(command.data.name, command);
client.commandArray.push(command.data.toJSON());
}
}

const rest = new REST({
version: '9'
}).setToken(process.env.token);

(async () => {
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);
}
})();
};
};
this is handelcomands code
SpecialSauce
SpecialSauce11mo ago
At least one of your commands does not have a data property.
kjuaeldcanarion
kjuaeldcanarion11mo ago
ok i had a command with nothing writted on it
kjuaeldcanarion
kjuaeldcanarion11mo ago
but now i have another error, so i created a reaction roles command but when i execute it this happens and this error pops up on the vsc cmd
PS C:\Users\kjuan\Desktop\v14 slash> node .
Started refreshing application (/) commands.
Successfully reloaded application (/) commands.
Ready!
MongooseError: Operation `rrs.findOne()` buffering timed out after 10000ms
at Timeout.<anonymous> (C:\Users\kjuan\Desktop\v14 slash\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:23)
at listOnTimeout (node:internal/timers:569:17)
at process.processTimers (node:internal/timers:512:7)
node:events:491
throw er; // Unhandled 'error' event
^

DiscordAPIError[40060]: Interaction has already been acknowledged.
at handleErrors (C:\Users\kjuan\Desktop\v14 slash\node_modules\@discordjs\rest\dist\index.js:640:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (C:\Users\kjuan\Desktop\v14 slash\node_modules\@discordjs\rest\dist\index.js:736:23)
at async REST.request (C:\Users\kjuan\Desktop\v14 slash\node_modules\@discordjs\rest\dist\index.js:1387:22)
at async ChatInputCommandInteraction.reply (C:\Users\kjuan\Desktop\v14 slash\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:111:5)
at async Object.execute (C:\Users\kjuan\Desktop\v14 slash\src\events\interactionCreate.js:18:13)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
requestBody: {
files: [],
json: {
type: 4,
data: {
content: 'There was an error while executing this command!',
tts: false,
nonce: undefined,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: 64,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined
}
}
},
rawError: {
message: 'Interaction has already been acknowledged.',
code: 40060
},
code: 40060,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1131393120681066576/aW50ZXJhY3Rpb246MTEzMTM5MzEyMDY4MTA2NjU3NjozTEtIeE1MQVdTVjlYem41dklIYXlEQVRjT1BSMTJJQW5CUER6c3l6ell4QWRLZHJndjlQSDZHdnhaS3FMZW1mWnRkazRUY3ZZdW1iNEhwV3BDWWFFMDhsQ1p5ejgwSHhlMnRyQUE1SFhzNmtOMVQ4dW1YS0pWeDVCN21XNGQ5Vg/callback'
}

Node.js v18.16.1
PS C:\Users\kjuan\Desktop\v14 slash>
PS C:\Users\kjuan\Desktop\v14 slash> node .
Started refreshing application (/) commands.
Successfully reloaded application (/) commands.
Ready!
MongooseError: Operation `rrs.findOne()` buffering timed out after 10000ms
at Timeout.<anonymous> (C:\Users\kjuan\Desktop\v14 slash\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:23)
at listOnTimeout (node:internal/timers:569:17)
at process.processTimers (node:internal/timers:512:7)
node:events:491
throw er; // Unhandled 'error' event
^

DiscordAPIError[40060]: Interaction has already been acknowledged.
at handleErrors (C:\Users\kjuan\Desktop\v14 slash\node_modules\@discordjs\rest\dist\index.js:640:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (C:\Users\kjuan\Desktop\v14 slash\node_modules\@discordjs\rest\dist\index.js:736:23)
at async REST.request (C:\Users\kjuan\Desktop\v14 slash\node_modules\@discordjs\rest\dist\index.js:1387:22)
at async ChatInputCommandInteraction.reply (C:\Users\kjuan\Desktop\v14 slash\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:111:5)
at async Object.execute (C:\Users\kjuan\Desktop\v14 slash\src\events\interactionCreate.js:18:13)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
requestBody: {
files: [],
json: {
type: 4,
data: {
content: 'There was an error while executing this command!',
tts: false,
nonce: undefined,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: 64,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined
}
}
},
rawError: {
message: 'Interaction has already been acknowledged.',
code: 40060
},
code: 40060,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1131393120681066576/aW50ZXJhY3Rpb246MTEzMTM5MzEyMDY4MTA2NjU3NjozTEtIeE1MQVdTVjlYem41dklIYXlEQVRjT1BSMTJJQW5CUER6c3l6ell4QWRLZHJndjlQSDZHdnhaS3FMZW1mWnRkazRUY3ZZdW1iNEhwV3BDWWFFMDhsQ1p5ejgwSHhlMnRyQUE1SFhzNmtOMVQ4dW1YS0pWeDVCN21XNGQ5Vg/callback'
}

Node.js v18.16.1
PS C:\Users\kjuan\Desktop\v14 slash>