Error when handling commands

TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received undefined at new NodeError (node:internal/errors:393:5) at validateString (node:internal/validators:163:11) at Module.require (node:internal/modules/cjs/loader:1054:3) at require (node:internal/modules/cjs/helpers:103:18) at Object.<anonymous> (C:\Users\luizs\Documents\Bot\commands\create.js:1:118) at Module._compile (node:internal/modules/cjs/loader:1159:14) at Module._extensions..js (node:internal/modules/cjs/loader:1213:10) at Module.load (node:internal/modules/cjs/loader:1037:32) at Module._load (node:internal/modules/cjs/loader:878:12) at Module.require (node:internal/modules/cjs/loader:1061:19) { code: 'ERR_INVALID_ARG_TYPE' }
13 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Ashura
AshuraOP3y ago
corrected it but now is this error TypeError: Cannot read properties of undefined (reading 'toJSON') at Object.<anonymous> (C:\Users\luizs\Documents\Bot\deploy-commands.js:12:32) at Module._compile (node:internal/modules/cjs/loader:1159:14) at Module._extensions..js (node:internal/modules/cjs/loader:1213:10) at Module.load (node:internal/modules/cjs/loader:1037:32) at Module._load (node:internal/modules/cjs/loader:878:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:23:47
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Ashura
AshuraOP3y ago
gonna show u guys
const { REST, Routes } = require('discord.js');
const { clientId, guildId, token } = require('./config.json');
const fs = require('node:fs');

const commands = [];

const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));


for (const file of commandFiles) {
const command = require(`./commands/${file}`);
commands.push(command.data.toJSON());
}


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


(async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);


const data = await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {

console.error(error);
}
})();
const { REST, Routes } = require('discord.js');
const { clientId, guildId, token } = require('./config.json');
const fs = require('node:fs');

const commands = [];

const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));


for (const file of commandFiles) {
const command = require(`./commands/${file}`);
commands.push(command.data.toJSON());
}


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


(async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);


const data = await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {

console.error(error);
}
})();
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Ashura
AshuraOP3y ago
it does
Ashura
AshuraOP3y ago
idk why it isnt working in my pc in my notebook with the same code was alright laptop*
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Ashura
AshuraOP3y ago
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Ashura
AshuraOP3y ago
how can i make it work?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Ashura
AshuraOP3y ago
ooohhh didnt notice it thx a lot
Want results from more Discord servers?
Add your server