Discord Bot Slash Command Registration Issues

I’m working on creating a Discord bot using discord.js and running into problems with slash command setup. My bot can respond to regular messages just fine, but the slash commands won’t register properly.

import { REST, Routes } from 'discord.js';
const BOT_TOKEN = 'my_bot_token_here';
const APPLICATION_ID = 'my_app_id_here';

const slashCommands = [
  {
    name: 'hello',
    description: 'Bot says hello back',
  },
];

const restClient = new REST({ version: '10' }).setToken(BOT_TOKEN);

try {
  console.log('Starting command registration...');

  await restClient.put(Routes.applicationCommands(APPLICATION_ID), { body: slashCommands });

  console.log('Commands registered successfully!');
} catch (err) {
  console.error(err);
}

I’ve double checked my bot token and application ID multiple times. The code runs without any errors in the console, but the slash command doesn’t appear in Discord. What could be going wrong here?

Your registration code runs fine, but Discord’s probably caching the old state. I’ve hit this exact issue - everything looks right but commands stay invisible. First, kick your bot from the server completely and re-add it with fresh OAuth2 permissions. Discord loves holding onto old states even after you update permissions. Second, double-check your APPLICATION_ID matches what’s in the General Information tab - not the bot’s user ID (they’re different). This mismatch is sneaky - registration works but commands never show up. Last thing: make sure you’re testing in the right spot. Global commands won’t appear in DMs, and some Discord clients cache commands hard. Try a fresh server or incognito session. Also throw some error handling around that Routes call - Discord’s API will return success while quietly rejecting commands for weird validation reasons.

Skip the debugging mess. Manual Discord bot deployment sucks.

Your code’s probably fine - you’re just hitting Discord’s caching issues, permission problems, and deployment headaches. That’s exactly why I ditched the old way of managing bots.

I built a Latenode workflow that handles everything: registration, updates, different environments, error handling. All automatic. No more guessing if commands registered or dealing with Discord’s wonky caching.

The workflow watches my code repo and pushes command updates when I make changes. Handles guild vs global commands, manages separate bot instances for testing and production, and pings me when stuff breaks.

Beats manually running registration scripts and hoping Discord cooperates. Set it once, never worry about deployment again.

your bot proably doesn’t have the right intents enabled. Slash commands can register fine but won’t show up without proper intents in your main bot file. You need GatewayIntentBits.Guilds at minimum when creating your client instance. Also restart Discord completely - sometimes it just won’t refresh commands until you do that

Had the same headache a few months back. It’s usually timing and scope.

Your code looks fine, but Discord takes up to an hour to show new slash commands. Global commands are slow to propagate.

Try registering to a specific guild for testing:

await restClient.put(
  Routes.applicationGuildCommands(APPLICATION_ID, 'your_guild_id_here'),
  { body: slashCommands }
);

Guild commands show up instantly.

I actually automate the entire Discord bot workflow with Latenode now. No more manual command registration or deployment headaches. Set up the automation once and it handles everything.

I’ve got workflows that automatically register commands, update them when I push code changes, and handle different environments. Way cleaner than managing this manually.

Check it out: https://latenode.com

Check if you’re wrapping the registration code in an async function properly. I hit this exact issue - my code looked right but the await wasn’t executing correctly. Console logs showed up but the API call never fired. Also add some debugging to log Discord’s actual response. Sometimes the put request works but returns command validation warnings you’d miss. One thing that got me: if you’ve been testing with different bots or changed your app setup recently, Discord might have stale data tied to your account. Test the slash command from a completely different Discord account, not just another server. The command might be registered but only visible to other users because of weird client caching on your end.

Check your bot permissions in the Discord Developer Portal. Even with the right token, slash commands won’t work without the applications.commands scope. You probably missed this when inviting your bot. Go to your app settings → OAuth2 and make sure applications.commands is checked when you generate the invite URL. You’ll need to re-invite the bot. Also, global commands don’t work in DMs - the bot needs to share a server with you. I wasted hours debugging this same issue before I caught the missing permission.