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)
    })
}


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
Was this page helpful?