Discord Bot Shows Online Status But Won't Respond to Commands

Bot Won’t Execute Commands Despite Being Online

I’m working on a Discord bot that should fetch motivational quotes when users type a specific command. The bot appears online in my server and has all necessary permissions, but it’s not responding to any commands.

import discord
import os
import requests
import json

bot_intents = discord.Intents.default()
bot_client = discord.Client(intents=bot_intents)

def fetch_motivation():
    api_response = requests.get("https://zenquotes.io/api/random")
    response_data = json.loads(api_response.text)
    motivational_text = response_data[0]['q'] + " - " + response_data[0]['a']
    return motivational_text

@bot_client.event
async def on_ready():
    print(f'Bot is ready as {bot_client.user}')

@bot_client.event
async def on_message(msg):
    if msg.author == bot_client.user:
        return
    
    if msg.content.startswith('!motivate'):
        inspiration = fetch_motivation()
        await msg.channel.send(inspiration)

bot_client.run(os.environ['BOT_TOKEN'])

I’m using Python and hosting this on Replit. The bot should send a random inspirational quote whenever someone types the trigger command, but nothing happens when I test it in my Discord server. What could be causing this issue?

Yeah, looks like a message content intent issue. Discord changed this a while back - you need to explicitly enable it in the dev portal or your bot can’t see message content. Also try adding print(f'message received: {msg.content}') right after your author check to see if it’s even getting messages.

Your issue is you’re using discord.Client() instead of discord.Bot() or commands.Bot(). Client doesn’t handle commands - it only listens for events like messages. Your on_message event should work though. If it’s not firing at all, check your bot’s message content intent in the Discord Developer Portal. You need to enable “Message Content Intent” under the Bot section. I hit this exact problem last year when Discord made it required. Also double-check your bot token is set correctly in your Replit environment variables.

Had the same frustrating issue with my first Replit bot. Your code looks fine for a Client-based bot, but there’s a common gotcha with hosting environments. Add some debug prints in your on_message event to see if it’s even triggering. Also check if Replit’s going to sleep - free accounts have limited uptime and your bot might be disconnecting. You can verify this by watching the console output. Make sure your bot has permission to read messages in the channel you’re testing. Sometimes the bot role gets restricted without you realizing it. The message content intent issue is probably the real culprit though if you created the bot recently.