#Global and Local
1 messages · Page 1 of 1 (latest)
hello
eval guild.commands possibly with a map or something to see what all is contained in it
I am still trying to update to discord v14 from v13.2, so I just basically reprogrammed my whole entire bot, doing this, I used the discordjs.guide and got the deploy-commands.js
possibly cache
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 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 {
// 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),
{ 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);
}
})();
This is where the script comes in
I do realise that I changed it to
Routes.applicationCommands(clientId),
instead of the guildCommands or w/e
did you ever delete the guild-deployed commands
To my knowledge, yes
But there is a chance that I have done it incorrectly
before we even get to it, do you have duplicate commands?
I do not have duplicate commands
yes, they showed a ss earlier
just confirming the issue
not in your files, in discord client
when you type /ping, do multiple commands come up?
GuildApplicationCommandManager#cache
The cache of this manager
Is that it is only for older commands, newer commands only have one shown (as it should)
check this collection
are commands cached now? i used to know they had to be fetched
there's a cache for them, i dunno if it's populated on ready or needs to be fetched
i've also never made a slash command 
Forgive me since I am still trying to learn discord v14 
But I'm not sure how to properly check for these "cached" commands
I
DO NOT LIKE SLASH COMMANDS 
They're amazing and cool and efficient
But programming them, I hate it 
i told you to check the guild commands
With respect, Mark
In other words, I do not understand what you are asking for me to do
.
check this collection
on the guild where the command is duplicated
asking you to log it in the bot process
this would not work in the deploy-commands script since there is no client 😛
do i type
guild.commands.delete('ping')
.then(console.log)
.catch(console.error);
into deploy-commands.js and run it?
nope
log guild.commands.cache on somewhere like your ready event
I am literally autistic /gen
So I'm sorry if I'm being dumb 
it's perfectly fine
Ran, Guild is not defined
does it take a guildId?
client.guilds.cache.get("guildId")
the id of this guild right here
you know what, why are we going through so much trouble smh
like it's obvious there's a guild command registered
got an [object Map]
@knotty mango you want to remove all the guild-specific commands and just keep the globals right?
because jumping steps does not always help users understand
what is there to understand, there's a duplicate, one's a global, one's a guild command
I understand the steps, I understand that we are checking to make sure that the commands are in the actual guild, as well as globally
And we are just removing them from the guild side, so it is global only
so in your script, temporary change it to this ts const data = await rest.put( Routes.applicationGuildCommands(clientId, guildId), { body: commands }, ); in there, you don't want any commands, so the body would have an empty array, {body: []} like so
running that script afterwards would remove all the guild commands registered to that guild

It's fixed now
Thanks, Ben 
And thank you as well, Mark, I know you're just trying to prevent basic questions flogging #djs-help-v14