Discord bot shows ready status but stays offline - Python issue

I’m working on creating a Discord bot with Python and facing a weird problem. My bot prints the ready message in the console when I start it, but it doesn’t show up as online in my Discord server. I’ve double checked that my token is correct in the .env file and the bot has all necessary permissions.

import os
import discord
from discord.ext import commands
from dotenv import load_dotenv

load_dotenv()
BOT_TOKEN = os.getenv('BOT_TOKEN')

permissions = discord.Intents.default()
client = discord.Client(intents=permissions)
permissions.message_content = True

client = commands.Bot(command_prefix='$', intents=permissions)

@client.event
async def on_ready():
    print("Bot is now active")

@commands.command()
async def hello(ctx):
    await ctx.send("hello world")

client.add_command(hello)
client.run(BOT_TOKEN)

I’ve already added the bot to my server with admin permissions and made sure everything looks right. The bot appears to start successfully based on the console output, but it never shows as online in the member list. What could be causing this problem?

Had this exact issue last month - it was Discord’s caching acting up. The bot was connecting fine, but Discord wasn’t refreshing the member list. Try completely restarting Discord or check from another device to see if the bot shows online there. Discord can take a few minutes to update status, especially if you’ve been testing repeatedly. Also check the Developer Portal to make sure the bot wasn’t accidentally disabled or the token wasn’t regenerated.

hey, make sure your bot token is correct! also, double check you invited it using the OAuth2 link from the dev portal, not just added it manually. the ready event can trigger even if it’s not fully connected. good luck!

Your problem is that you’re creating two different client objects. You start with client = discord.Client(intents=permissions) then immediately overwrite it with client = commands.Bot(command_prefix='$', intents=permissions). This messes up your bot’s configuration. Also, make sure permissions.message_content = True comes before you create the Bot instance - it won’t apply to that first client otherwise. Just use the Bot instance and set all your intents properly before creating it. I ran into the same thing and it’s one of those small mistakes that’ll drive you crazy.