path is not defined

Problem
27 Replies
d.js toolkit
d.js toolkit2y 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.
Noam ♡
Noam ♡OP2y ago
Noam ♡
Noam ♡OP2y ago
If anyone wants I can give them a share code
MrMythical
MrMythical2y ago
you did not define path
Noam ♡
Noam ♡OP2y ago
I can send you the code privately and tell me what I did wrong because I don't understand it that much @Myth 🌈 Please
MrMythical
MrMythical2y ago
No thanks I'm good
Noam ♡
Noam ♡OP2y ago
I've been trying to create a bot for two years and it just doesn't work for me
sexy dark chocolate
Take about 2 days to learn javascript and read the discordjs guide and you'd be set for life Unless you forget of course, but then it'll be easier to remember
Noam ♡
Noam ♡OP2y ago
I am not speak English bro I only know basic English and what Danny is writing at the moment I am translating
sexy dark chocolate
Damn, that's gonna make it harder but I believe mdn allows the user to choose their language for the site
Noam ♡
Noam ♡OP2y ago
I speak Hebrew, it's not normal to have such an option Can someone maybe help me with this shit please .
MrMythical
MrMythical2y ago
Define path
Noam ♡
Noam ♡OP2y ago
Bro I did what they say and it doesn't work
MrMythical
MrMythical2y ago
Who is "they"?
Noam ♡
Noam ♡OP2y ago
Discord.js guide on their website
MrMythical
MrMythical2y ago
In which page
Noam ♡
Noam ♡OP2y ago
That's the code there
const { REST, Routes } = require('discord.js');
const { clientId, guildId, token } = require('./config.json');
const fs = require('node:fs');
const path = require('node:path');

const commands = [];
// Grab all the command files from the commands directory you created earlier
const foldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(foldersPath);

for (const folder of commandFolders) {
// Grab all the command files from the commands directory you created earlier
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
// Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
if ('data' in command && 'execute' in command) {
commands.push(command.data.toJSON());
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}

// Construct and prepare an instance of the REST module
const rest = new REST().setToken(token);

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

// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}
})();
const { REST, Routes } = require('discord.js');
const { clientId, guildId, token } = require('./config.json');
const fs = require('node:fs');
const path = require('node:path');

const commands = [];
// Grab all the command files from the commands directory you created earlier
const foldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(foldersPath);

for (const folder of commandFolders) {
// Grab all the command files from the commands directory you created earlier
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
// Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
if ('data' in command && 'execute' in command) {
commands.push(command.data.toJSON());
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}

// Construct and prepare an instance of the REST module
const rest = new REST().setToken(token);

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

// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}
})();
And I also made a config file and it doesn't work
MrMythical
MrMythical2y ago
Then you didn't do what it said
Noam ♡
Noam ♡OP2y ago
I yes
MrMythical
MrMythical2y ago
You no
Noam ♡
Noam ♡OP2y ago
Noam ♡
Noam ♡OP2y ago
What else do I need to add?
MrMythical
MrMythical2y ago
Which file do you use to deploy commands 🤨
Noam ♡
Noam ♡OP2y ago
commands
MrMythical
MrMythical2y ago
That's not a file
Noam ♡
Noam ♡OP2y ago
Oh Ping
MrMythical
MrMythical2y ago
That doesn't exist Please learn JS, ReferenceErrors are basic errors and should be easy to fix if you know JS There are lots of resources in #resources
Want results from more Discord servers?
Add your server