Bokuto
Bokuto
DIAdiscord.js - Imagine an app
Created by Bokuto on 3/29/2024 in #djs-questions
Slash commands not getting registered.
sorry
22 replies
DIAdiscord.js - Imagine an app
Created by Bokuto on 3/29/2024 in #djs-questions
Slash commands not getting registered.
i'm dumb, i've found the awnser
22 replies
DIAdiscord.js - Imagine an app
Created by Bokuto on 3/29/2024 in #djs-questions
Slash commands not getting registered.
i have to add something i'm missing?
22 replies
DIAdiscord.js - Imagine an app
Created by Bokuto on 3/29/2024 in #djs-questions
Slash commands not getting registered.
22 replies
DIAdiscord.js - Imagine an app
Created by Bokuto on 3/29/2024 in #djs-questions
Slash commands not getting registered.
here's my main.js:
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.commands = new Collection();
const foldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(foldersPath);

for (const folder of commandFolders) {
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}

client.login(token);
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.commands = new Collection();
const foldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(foldersPath);

for (const folder of commandFolders) {
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}

client.login(token);
22 replies
DIAdiscord.js - Imagine an app
Created by Bokuto on 3/29/2024 in #djs-questions
Slash commands not getting registered.
its like the code doesn't arrive in the deploy-commands.js
22 replies
DIAdiscord.js - Imagine an app
Created by Bokuto on 3/29/2024 in #djs-questions
Slash commands not getting registered.
nothing happens.
22 replies
DIAdiscord.js - Imagine an app
Created by Bokuto on 3/29/2024 in #djs-questions
Slash commands not getting registered.
but i dont know why
22 replies
DIAdiscord.js - Imagine an app
Created by Bokuto on 3/29/2024 in #djs-questions
Slash commands not getting registered.
like the archive arent getting readed
22 replies
DIAdiscord.js - Imagine an app
Created by Bokuto on 3/29/2024 in #djs-questions
Slash commands not getting registered.
the console's apperantly aren't getting readed
22 replies
DIAdiscord.js - Imagine an app
Created by Bokuto on 3/29/2024 in #djs-questions
Slash commands not getting registered.
My main:
22 replies
DIAdiscord.js - Imagine an app
Created by Bokuto on 3/29/2024 in #djs-questions
Slash commands not getting registered.
No description
22 replies
DIAdiscord.js - Imagine an app
Created by Bokuto on 3/29/2024 in #djs-questions
Slash commands not getting registered.
Unfortunately no
22 replies
DIAdiscord.js - Imagine an app
Created by Bokuto on 3/29/2024 in #djs-questions
Slash commands not getting registered.
deploy-commands.js
const { REST, Routes } = require('discord.js');
const { clientId, token } = require('./config.json');
const fs = require('node:fs');
const path = require('node:path');

const commands = [];
// Grab all the command folders 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.applicationCommands(clientId), // Remove the guildId parameter to deploy global commands
{ 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, token } = require('./config.json');
const fs = require('node:fs');
const path = require('node:path');

const commands = [];
// Grab all the command folders 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.applicationCommands(clientId), // Remove the guildId parameter to deploy global commands
{ 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);
}
})();
22 replies
DIAdiscord.js - Imagine an app
Created by Bokuto on 3/29/2024 in #djs-questions
Slash commands not getting registered.
No description
22 replies
DIAdiscord.js - Imagine an app
Created by Bokuto on 1/1/2023 in #djs-questions
Collection
but im not sure how to do it even with foreach
10 replies
DIAdiscord.js - Imagine an app
Created by Bokuto on 1/1/2023 in #djs-questions
Collection
and by how can i read i mean, i wanna get for example one user for each collection
10 replies
DIAdiscord.js - Imagine an app
Created by Bokuto on 1/1/2023 in #djs-questions
Collection
and yet i cant figure out
10 replies
DIAdiscord.js - Imagine an app
Created by Bokuto on 1/1/2023 in #djs-questions
Collection
but how can i read a collection?
10 replies