ThisCalculator

Everyday

Discord Bot Online But Not Responding: Find the Failure

Updated · Standard formula, shown below

If your Discord bot shows as online but doesn’t respond to commands, the failure is almost always in the code between the gateway connection and the command handler—often an unhandled promise rejection, a missing intent, or a permission check. This guide walks you through the most common causes and the exact steps to diagnose and fix each one.

Why a Bot Can Appear Online Yet Be Unresponsive

Discord marks a bot as “online” based solely on its WebSocket connection to Discord’s gateway. That connection is maintained by your bot’s login code—usually a few lines at the top of your main file. If that connection succeeds, Discord shows the bot as online, regardless of whether the rest of your code is working. Your command handler, event listeners, or message processing code could be crashing or silently failing without affecting the gateway connection. This is why a bot can look perfectly healthy while doing nothing.

Step-by-Step Diagnosis

  1. Check the console and logs. Run the bot in a terminal and watch for errors. Unhandled promise rejections, syntax errors, or stack traces will appear here. If you see an error, fix that first—it’s likely the whole problem.
  2. Test the gateway connection. Add a simple console.log('ready') inside the client.once('ready') event. If you don’t see it, your token or gateway connection is failing—but then the bot wouldn’t show online. So if you do see it, the connection is fine and the issue is elsewhere.
  3. Verify intents. If your bot uses message content (prefix commands) or guild members, you must enable the corresponding intents both in the Discord Developer Portal and in your code. Missing intents cause the bot to never receive message events, so it stays online but ignores everything.
  4. Check the command prefix and exact command name. A typo in the prefix or command name is the most common user error. Try the command exactly as defined, and check for case sensitivity.
  5. Look for permission errors. If the bot lacks the Send Messages or Embed Links permission in that channel, it will silently fail to respond. Check the channel permissions and the bot’s role.
  6. Test with a minimal command. Temporarily replace your command handler with a simple message.channel.send('pong') on any message. If that works, the issue is in your command logic, not the connection.

Common Causes and Fixes

  • Unhandled promise rejections: Async functions that throw errors without a catch will crash the handler. Wrap your command execution in a try/catch and log the error.
  • Missing intents: For discord.js v13+, you must specify GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, and GatewayIntentBits.MessageContent (for reading message content). Without them, the bot won’t see commands.
  • Incorrect command registration: If you use slash commands, they must be registered with Discord. If you changed the command definition but didn’t re-register, the old command may still work, or the new one may not appear.
  • Rate limiting: If your bot sends too many messages quickly, Discord will rate-limit it, and responses may be delayed or dropped. Check for loops that send messages repeatedly.
  • Global vs. guild commands: Slash commands can be registered globally (takes up to an hour to propagate) or per-guild (instant). If you’re testing a global command, wait or use a guild command for testing.

How to Read Error Messages

Error messages are your best clue. A DiscordAPIError: Unknown Message means you’re trying to edit or delete a message that no longer exists. Missing Access means the bot lacks permissions. Cannot read properties of undefined often means you’re trying to access a property that doesn’t exist—for example, message.member when the message is from a DM. Read the stack trace to find the exact line number, then open that file and inspect the code around it.

Testing with a Clean Slate

If you can’t find the error, create a minimal test bot in a new folder with just the essentials: login, a message event that replies to any message, and the required intents. If that works, gradually add your features until it breaks. This isolates the problem. A common mistake is to assume the issue is in the command handler when it’s actually in an event listener that throws an error and crashes the entire process—but because the gateway connection is already established, the bot stays online.

Frequently Asked Questions

Why does my bot show online but doesn’t respond to any commands?

This almost always means the bot isn’t receiving message events. Check that you’ve enabled the Message Content intent in the Developer Portal and in your code. Also verify that your command handler is actually listening for the correct event (e.g., messageCreate for prefix commands, or interactionCreate for slash commands).

My bot works on my computer but not on a hosting service. What’s different?

Hosting services often have different environment variables, file paths, or Node.js versions. Ensure your token is set correctly in the host’s environment, and that you’ve installed all dependencies. Also, some hosts block certain ports or have stricter rate limits—check their logs for errors.

How do I check if my bot is rate-limited?

Discord sends a X-RateLimit-Remaining header on API responses. If you see 0, you’re rate-limited. The bot will still show online, but API calls (like sending messages) will be delayed or fail. Add logging for these headers or use a library that handles rate limits automatically.

Why does my bot respond to some commands but not others?

This usually points to a specific command’s code throwing an error. Check the console for errors when you run that command. Also verify that the command name and arguments match exactly—a typo in an argument name can cause the command to fail silently.

My bot was working yesterday, now it’s not. What changed?

Check if Discord changed something (like a required intent) or if your hosting service updated Node.js. Also, if you edited the code, a syntax error could prevent the bot from loading the command handler. Review your recent changes and revert if necessary.

Can a bot be online but not actually connected to the gateway?

No. The online status is tied to the gateway connection. If the connection drops, the bot will show offline. If it shows online, the gateway connection is alive. The problem is always in the code that reacts to events, not the connection itself.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.