Commands not refreshing after being correctly deployed

Good evening. I'm developing a discord.js bot using typescript. I am having trouble using my deployed commands. To clarify, my bot integration successfully have the commands that I want to deploy but they are not visible within the channel I'm testing on. Here's my Commands.ts file to register the command and deploy them (public)
import { Client, Routes, SlashCommandBuilder } from "discord.js";
import { REST } from "@discordjs/rest"
import { readdirSync } from "fs";
import { join } from "path";
import { color } from "../functions";
import { SlashCommand } from "../types";

module.exports = (client : Client) => {
const slashCommands : SlashCommandBuilder[] = []

let slashCommandsDir = join(__dirname,"../slashCommands")

readdirSync(slashCommandsDir).forEach(file => {
if (!file.endsWith(".js")) return;
let command : SlashCommand = require(`${slashCommandsDir}/${file}`).default
slashCommands.push(command.command)
client.slashCommands.set(command.command.name, command)
})


const rest = new REST({version: "10"}).setToken(process.env.TOKEN);

rest.put(Routes.applicationCommands(process.env.CLIENT_ID), {
body: slashCommands.map(command => command.toJSON())
})
.then((data : any) => {
console.log(color("text", `🔥 Successfully loaded ${color("variable", data.length)} slash command(s)`))
}).catch(e => {
console.log(e)
})
}
import { Client, Routes, SlashCommandBuilder } from "discord.js";
import { REST } from "@discordjs/rest"
import { readdirSync } from "fs";
import { join } from "path";
import { color } from "../functions";
import { SlashCommand } from "../types";

module.exports = (client : Client) => {
const slashCommands : SlashCommandBuilder[] = []

let slashCommandsDir = join(__dirname,"../slashCommands")

readdirSync(slashCommandsDir).forEach(file => {
if (!file.endsWith(".js")) return;
let command : SlashCommand = require(`${slashCommandsDir}/${file}`).default
slashCommands.push(command.command)
client.slashCommands.set(command.command.name, command)
})


const rest = new REST({version: "10"}).setToken(process.env.TOKEN);

rest.put(Routes.applicationCommands(process.env.CLIENT_ID), {
body: slashCommands.map(command => command.toJSON())
})
.then((data : any) => {
console.log(color("text", `🔥 Successfully loaded ${color("variable", data.length)} slash command(s)`))
}).catch(e => {
console.log(e)
})
}
I find out that re-inviting the bot fixed the problem but I don't think this is a normal behaviour, since a public bot should have its command refreshed automatically in any server it's in, right ? Thanks for your help
DT
d.js toolkit45d 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!
D
darp45d ago
restart your discord client?
S
Sourceae45d ago
This actually worked but is this the expected behaviour ? Should anyone restart its discord client to get a bot commands updates ?
D
darp45d ago
discord client is just bad at syncing them
S
Sourceae45d ago
Thanks for the clarification 🙏
Want results from more Discord servers?
Add your server
More Posts
guild.guildScheduledEventUserAdd event failing to fire consistentlyI am having an issue with the guildScheduledEventUserAdd event. It seems to trigger sometimes but whWhere do I start from?Hi, Can y'all share some helpful resouces with me so that I can understand and learn about npmjs?? THelp me plsCode: Error: `[WARNING] The command at C:\Users\OE104655\Videos\Eendsmp bot\commands\utility\giveawHelp me plsIdk whats wrong with this line of code: `const client = new Client({ intents: [GatewayIntentBits.Guiis it possible to run command 1 from command 2so like command 1 is /embed title: description: And i want to run that command with pre-set values fHow do I add a role with discord.js```js const target = interaction.options.getUser('target'); const role = interaction.options.getRolecheck if role is set to certain role idshow do i check if the role is set to certain ids? ```js const role = interaction.optHow do you turn on a discord bot?It ain't onErrorroot@VPS-10384:~/7bLogsBot# node index node:internal/modules/cjs/loader:1137 throw err; ^ ErrorTypeErrorCode: `const guild = bot.guilds.cache.get(process.env.GUILD_ID);` Error: `TypeError: Cannot read Modal — PaginationHi! To construct my bot, I wanted to use modals allowing user reply. But my number of fields is moreduplicated interactionsokay i need help, because i have been hititng my head against the wall abt this for days. my interacMaintaining connection after restarting nodeI have a bot that would connect to a channel and play sounds. I have a slash command that would playMessages: combining selectors and input fieldsHey, Is it possible for example with modals or messages to have a combination of inputs for free tex