Discord Bot Commands Function in DMs But Not in Server Channels

I created a Discord bot that plays rock-paper-scissors with users. The bot works perfectly when I send commands through direct messages, but it completely ignores commands when posted in server text channels.

import discord
import random

BOT_TOKEN = 'YOUR_BOT_TOKEN_HERE'
COMMAND_PREFIX = '!'

intents = discord.Intents.default()
intents.typing = False
intents.presences = False

bot = discord.Client(intents=intents)

@bot.event
async def on_ready():
    print(f'Bot {bot.user} is now online!')

@bot.event
async def on_message(msg):
    if msg.author == bot.user:
        return
    
    if msg.content.startswith(COMMAND_PREFIX + 'rps'):
        await play_rock_paper_scissors(msg)
    
    if msg.content.startswith(COMMAND_PREFIX + 'rpsb'):
        await play_rps_with_nuke(msg)

async def play_rock_paper_scissors(msg):
    options = ['Rock', 'Paper', 'Scissors']
    bot_choice = random.choice(options)
    user_choice = msg.content[len(COMMAND_PREFIX + 'rps'):].strip().title()
    
    if user_choice not in options:
        await msg.channel.send("Invalid choice. Please use 'Rock', 'Paper' or 'Scissors'.")
        return
    
    if bot_choice == user_choice:
        result = 'It\'s a tie!'
    elif (bot_choice == 'Rock' and user_choice == 'Scissors') or (bot_choice == 'Scissors' and user_choice == 'Paper') or (bot_choice == 'Paper' and user_choice == 'Rock'):
        result = f'I picked {bot_choice}. You lost!'
    else:
        result = f'I picked {bot_choice}. You won!'
    
    await msg.channel.send(result)

async def play_rps_with_nuke(msg):
    options = ['Rock', 'Paper', 'Scissors', 'Nuke']
    bot_choice = random.choice(options)
    user_choice = msg.content[len(COMMAND_PREFIX + 'rpsb'):].strip().title()
    
    if user_choice not in options:
        await msg.channel.send("Invalid choice. Use 'Rock', 'Paper', 'Scissors' or 'Nuke'.")
        return
    
    if bot_choice == user_choice:
        result = 'It\'s a tie!'
    elif (bot_choice == 'Rock' and user_choice == 'Scissors') or (bot_choice == 'Scissors' and user_choice == 'Paper') or (bot_choice == 'Paper' and user_choice == 'Rock'):
        result = f'I picked {bot_choice}. You lost!'
    elif bot_choice == 'Nuke' and user_choice != 'Paper':
        result = f'I picked {bot_choice}. You won!'
    else:
        result = f'I picked {bot_choice}. You lost!'
    
    await msg.channel.send(result)

bot.run(BOT_TOKEN)

The weird thing is that the bot responds instantly when I message it directly, but when I type the same commands in server channels, nothing happens. The bot shows as online and I gave it administrator permissions just to be sure. What could be causing this issue?

Had the exact same problem a few months back - drove me crazy for hours. Discord now requires privileged intents for message content in servers. Go to your Discord Developer Portal, find your bot application, hit the Bot section, and scroll down to Privileged Gateway Intents. Enable “Message Content Intent” there. Then in your code, add intents.message_content = True right after you create your intents object. Without both steps, your bot sees messages exist but can’t read their content in servers. DMs work differently and don’t need this intent, which is why your bot responds there but stays silent in channels.

Same thing happened to me last year. You need to do two things: enable message content intent in the dev portal AND add intents.message_content = True in your code before the bot client line. Discord changed this in 2022, so older tutorials miss it. That’s why DMs work but servers don’t - they use different permission systems.

This is definitely a message content intent issue. Discord changed their API in 2022 - bots now need to explicitly request message content intent to read messages in servers. You’re missing this permission in your intents config.

Add intents.message_content = True to your intents setup before creating the bot client. Without it, your bot gets message events but can’t access the actual content in servers. That’s why DMs work but server channels don’t - DMs have different permission requirements.

Also enable message content intent in your bot settings on Discord Developer Portal (Bot section). You need both the code change AND the portal setting.