kjuaeldcanarion
kjuaeldcanarion
DIAdiscord.js - Imagine an app
Created by kjuaeldcanarion on 7/20/2023 in #djs-questions
error on handelcomands though i didnt wrote anything there
ok i had a command with nothing writted on it
9 replies
DIAdiscord.js - Imagine an app
Created by kjuaeldcanarion on 7/20/2023 in #djs-questions
error on handelcomands though i didnt wrote anything there
this is handelcomands code
9 replies
DIAdiscord.js - Imagine an app
Created by kjuaeldcanarion on 7/20/2023 in #djs-questions
error on handelcomands though i didnt wrote anything there
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);
}
})();
};
};
9 replies
DIAdiscord.js - Imagine an app
Created by kjuaeldcanarion on 7/20/2023 in #djs-questions
error on handelcomands though i didnt wrote anything there
this is the full error
9 replies
DIAdiscord.js - Imagine an app
Created by kjuaeldcanarion on 7/20/2023 in #djs-questions
error on handelcomands though i didnt wrote anything there
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>
9 replies