reload command on new sever

So right now when i bot is invited to a new server you cant cant see any commands untill i restart the bot
4 Replies
d.js toolkit
d.js toolkit13mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Dustshader
DustshaderOP13mo ago
how do i do that
d.js docs
d.js docs13mo ago
guide Creating Your Bot: Registering slash commands - Command registration > Global commands read more
Dustshader
DustshaderOP13mo ago
i followed that tho, thats why im confused what file are you looking for ok maybe i dont have that
const config = require("../Structures/config.json")
const { Perms } = require("../Validation/Permissions");
const { Client, ClientUser } = require("discord.js");

/**
* @param {Client} client
*/
module.exports = async (client,PG, Ascii) => {
const Table = new Ascii("Command Loaded")

CommandsArray = [];

(await PG(`${process.cwd()}/Commands/*/*.js`)).map(async (file) => {
const command = require(file);
if(!command.name)
return Table.addRow(file.split("/")[7], "❌ FAILED", "Missing a name.")

if (command.type !== "USER" && !command.description)
return Table.addRow(command.name, "🔸 FAILED", "missing a description.");

if(command.permission) {
if(Perms.includes(command.permission))
command.defaultPermission = false;
else
return Table.addRow(command.name, "❌ FAILED", "Permission invalid.")
}

client.commands.set(command.name, command);
CommandsArray.push(command);

await Table.addRow(command.name, "✔ SUCCESSFUL");

});

console.log(Table.toString());

client.on('ready', async () => {
client.guilds.cache.forEach((guild) => {
guild.commands.cache.delete();
guild.commands.set(CommandsArray);
})
});
};
//const MainGuild = await client.guilds.cache.get(config.ServerID);
//MainGuild.commands.set(CommandsArray);
const config = require("../Structures/config.json")
const { Perms } = require("../Validation/Permissions");
const { Client, ClientUser } = require("discord.js");

/**
* @param {Client} client
*/
module.exports = async (client,PG, Ascii) => {
const Table = new Ascii("Command Loaded")

CommandsArray = [];

(await PG(`${process.cwd()}/Commands/*/*.js`)).map(async (file) => {
const command = require(file);
if(!command.name)
return Table.addRow(file.split("/")[7], "❌ FAILED", "Missing a name.")

if (command.type !== "USER" && !command.description)
return Table.addRow(command.name, "🔸 FAILED", "missing a description.");

if(command.permission) {
if(Perms.includes(command.permission))
command.defaultPermission = false;
else
return Table.addRow(command.name, "❌ FAILED", "Permission invalid.")
}

client.commands.set(command.name, command);
CommandsArray.push(command);

await Table.addRow(command.name, "✔ SUCCESSFUL");

});

console.log(Table.toString());

client.on('ready', async () => {
client.guilds.cache.forEach((guild) => {
guild.commands.cache.delete();
guild.commands.set(CommandsArray);
})
});
};
//const MainGuild = await client.guilds.cache.get(config.ServerID);
//MainGuild.commands.set(CommandsArray);
const { Client, Collection } = require('discord.js');
const { promisify } = require("util");
const { glob } = require("glob");
const Ascii = require("ascii-table");
const client = new Client({
intents: 131071,
partials: ["MESSAGE", "CHANNEL", "REACTION"]
});
const { Token, STATUS } = require("./config.json");

client.commands = new Collection();

// Define PG using promisify and glob
const PG = promisify(glob);

module.exports = client;

["Events", "Commands"].forEach(handler => {
require(`../Handlers/${handler}`)(client, PG, Ascii)
});


client.login(Token);
const { Client, Collection } = require('discord.js');
const { promisify } = require("util");
const { glob } = require("glob");
const Ascii = require("ascii-table");
const client = new Client({
intents: 131071,
partials: ["MESSAGE", "CHANNEL", "REACTION"]
});
const { Token, STATUS } = require("./config.json");

client.commands = new Collection();

// Define PG using promisify and glob
const PG = promisify(glob);

module.exports = client;

["Events", "Commands"].forEach(handler => {
require(`../Handlers/${handler}`)(client, PG, Ascii)
});


client.login(Token);
i was watching a yt video that was using this guide
Want results from more Discord servers?
Add your server