Hey everyone! I’m working on my first Discord bot and running into a weird issue. The bot responds to regular messages just fine, but I can’t get slash commands to register properly. I followed the official discord.js docs but something isn’t working right.
I double checked my bot token and application ID multiple times. The strange part is that no errors show up in the console at all. The registration code runs without any problems but the slash command just doesn’t appear in Discord.
Had this exact problem when I started building bots. Your code looks fine - it’s probably a permissions issue. Check if your bot has the applications.commands scope when you invited it. If you added the bot before setting up slash commands, you’ll need to re-invite it with the right scopes. Go to OAuth2 in your Discord Developer Portal and make sure both bot and applications.commands are selected, then use that new invite link. This got me too since regular message handling doesn’t need the applications.commands scope.
This might be an intents issue. Slash commands don’t need specific intents to register, but I’ve seen cases where the bot client needs proper initialization first. Try moving your registration code into your main bot file after the client’s ready, or run the registration script separately from your main bot.
Also check if you’re accidentally running the registration multiple times - Discord caches old registrations and can ignore new ones when there’s conflicting data. I throw in a small delay between attempts when testing since rate limiting doesn’t always show up as an error.
sounds like a scope issue. try registering the commands to a specific guild first instead of globally. use Routes.applicationGuildCommands(APP_ID, GUILD_ID) - they’ll show up instantly for testing. global commands can take up to an hour to appear.