Commands don't seem to update at all

I have tried re-deploying commands again, restarting my bot, restarting my Discord client, reinviting my bot to the server, checking the intents on discord.dev, and still nothing, I'm genuinely lost. I have also tried running the program with a different bot, but the commands don't even show up, and there's also no errors in the console. Is there something else I can do to troubleshoot this?
25 Replies
d.js toolkit
d.js toolkit2mo 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!
Shavix
ShavixOP2mo ago
index.js:
// Require the necessary discord.js classes
const { Client, Events, GatewayIntentBits, REST, Routes } = require('discord.js');
require('dotenv').config(); // Load environment variables from .env file
const token = process.env.TOKEN;

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

// When the client is ready, run this code (only once).
// The distinction between `client: Client<boolean>` and `readyClient: Client<true>` is important for TypeScript developers.
// It makes some properties non-nullable.
client.once(Events.ClientReady, readyClient => {
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
});

// Log in to Discord with your client's token
client.login(token);
// Require the necessary discord.js classes
const { Client, Events, GatewayIntentBits, REST, Routes } = require('discord.js');
require('dotenv').config(); // Load environment variables from .env file
const token = process.env.TOKEN;

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

// When the client is ready, run this code (only once).
// The distinction between `client: Client<boolean>` and `readyClient: Client<true>` is important for TypeScript developers.
// It makes some properties non-nullable.
client.once(Events.ClientReady, readyClient => {
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
});

// Log in to Discord with your client's token
client.login(token);
deploy-commands.js:
const { REST, Routes } = require('discord.js');
const fs = require('fs');
require('dotenv').config(); // Load environment variables from .env file

// Get all commands from the commands folder
const commands = [];
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));

// Loop over all the files in the commands folder and add them to the commands array
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
commands.push(command.data.toJSON());
}

// Create a new REST instance
const rest = new REST({ version: '9' }).setToken(process.env.TOKEN);

// Refresh the commands
(async () => {
try {
console.log('Started refreshing application (/) commands.');
// Put the commands in the guild
await rest.put(
Routes.applicationGuildCommands(process.env.CLIENT_ID, process.env.GUILD_ID),
{ body: commands },
);

console.log('Successfully reloaded application (/) commands.');
} catch (error) {
// Catch any errors and log them to the console
console.error(error);
}
})();
const { REST, Routes } = require('discord.js');
const fs = require('fs');
require('dotenv').config(); // Load environment variables from .env file

// Get all commands from the commands folder
const commands = [];
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));

// Loop over all the files in the commands folder and add them to the commands array
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
commands.push(command.data.toJSON());
}

// Create a new REST instance
const rest = new REST({ version: '9' }).setToken(process.env.TOKEN);

// Refresh the commands
(async () => {
try {
console.log('Started refreshing application (/) commands.');
// Put the commands in the guild
await rest.put(
Routes.applicationGuildCommands(process.env.CLIENT_ID, process.env.GUILD_ID),
{ body: commands },
);

console.log('Successfully reloaded application (/) commands.');
} catch (error) {
// Catch any errors and log them to the console
console.error(error);
}
})();
Shavix
ShavixOP2mo ago
The commands are also in the right directory
No description
treble/luna
treble/luna2mo ago
did you actually run the deploy script
Shavix
ShavixOP2mo ago
A billion times.
treble/luna
treble/luna2mo ago
Not your bot
Shavix
ShavixOP2mo ago
node deploy-commands.js, right?
treble/luna
treble/luna2mo ago
yes, or whatever you named your file and did you log to confirm you are actually sending data
Shavix
ShavixOP2mo ago
I did
No description
treble/luna
treble/luna2mo ago
this then
Shavix
ShavixOP2mo ago
How should I do that?
d.js docs
d.js docs2mo ago
:mdn: console: log() static method The console.log() static method outputs a message to the console.
treble/luna
treble/luna2mo ago
You really shoukd know how to log stuff by now..
Shavix
ShavixOP2mo ago
I meant as in how can I get the commands I'm trying to deploy, I know about console.log I hope you understand what I mean
treble/luna
treble/luna2mo ago
You just log the body you deploy You named it commands
Shavix
ShavixOP2mo ago
It returned an empty table.
Shavix
ShavixOP2mo ago
No description
Steve
Steve2mo ago
Are there commands in ./commands?
treble/luna
treble/luna2mo ago
You are using subfolders Your code does not account for subfolders
Shavix
ShavixOP2mo ago
Moving the commands into the commands folder finally registered the commands, I was just following the discord js guide and usually putting the commands into commands\utility had no problems. But now the commands aren't working and there are no errors in the console as well.
treble/luna
treble/luna2mo ago
and do you listen for the interactionCreate event anywhere also, the guide uses subfolders, so you should adapt your deploy code to use subfolders Not the other way around
Shavix
ShavixOP2mo ago
It does not, should I create a file for that? I will look into it
treble/luna
treble/luna2mo ago
depends on how your event handler works
Shavix
ShavixOP2mo ago
I don't know if anyone will see this, but I did make a console.log for every interactionCreate event, and when I do run a slash command, it does log the ChatInputCommandInteraction, but still no errors show up in the console or does the bot reply.
treble/luna
treble/luna2mo ago
every? You only need one Then use command handling for commands and a similar approach for buttons and other components

Did you find this page helpful?