My Discord bot won't respond to commands - what's wrong?

Hey everyone, I’m having trouble with my Discord bot. It shows as online and is connected to my server with all the right permissions, but it just won’t respond when I type commands. I’ve been trying to figure this out for hours but can’t see what I’m doing wrong.

Here’s my code:

import discord

# Bot token
BOT_TOKEN = "your_token_here"

# Set up intents
intents = discord.Intents.default()
intents.message_content = True  # Allow bot to read message content

# Initialize client
bot = discord.Client(intents=intents)

@bot.event
async def on_ready():
    await bot.change_presence(activity=discord.Game(name="Testing Bot"))
    print(f'{bot.user} is now active!')

@bot.event
async def on_message(msg):
    if msg.author.bot:
        return
    
    # Check if message is in specific channel
    if msg.channel.name == 'commands':
        if '!info' in msg.content:
            await msg.channel.send('Here are the current details:')

# Start the bot
bot.run(BOT_TOKEN)

The bot connects fine but nothing happens when I use the command. Any ideas what might be causing this issue?

Your command detection logic is the problem. Using ‘!info’ in msg.content triggers on any message with those characters, even partial matches. Switch to msg.content.startswith(‘!info’) for proper command parsing. Also make sure you’re typing commands in a channel called exactly ‘commands’ - it’s case sensitive. I had the same issue when I started - my channel was ‘Commands’ with a capital C. Add a debug print like print(f’Message received: {msg.content} in channel: {msg.channel.name}') right after the bot check to see what’s actually getting processed.

Your problem’s probably that you’re using discord.Client instead of discord.Bot. Right now your setup only responds in a channel called ‘commands’ - if that’s not where you’re testing, nothing will happen. Try changing the channel name check to match your actual channel, or just remove it completely for testing. Also, make sure your bot has permissions to send messages there. Throw in some print statements to see if the bot’s even picking up your messages.

bruh the issue might be your channel check - are you actually typing in a channel named ‘commands’? also try adding some debug prints to see if the on_message event is even firing. remove the channel name restriction temporarily and test again, bet it’ll work then

Your code has a basic architecture problem. You’re using discord.Client but parsing commands manually in on_message events. It works, but it’ll bite you as your bot gets bigger. The real issue is probably the channel restriction - your bot only responds in channels called exactly ‘commands’. Discord channel names are case and space sensitive, so double-check that. I hit the same wall building my first bot last year. What saved me was temporarily removing the channel check and adding print(f'Processing: {msg.content}') right after the bot author check. You’ll see exactly which messages get processed. Once that’s working, add the channel restriction back. Eventually you should switch to commands.Bot from discord.ext - it handles command parsing way better than manual string checking.

Had the same issue yesterday lol. Your bot’s only listening in the ‘commands’ channel but you’re probably testing elsewhere. Remove the channel.name check temporarily and see if it responds. Also make sure you actually have a channel called ‘commands’ and not ‘general’ or something else

Your main issue is mixing Discord.py approaches. You’re using discord.Client but trying to handle commands manually - that gets messy fast.

I hit this same problem months ago building a bot for our team. Wasted tons of time debugging command parsing and channel restrictions.

What fixed it for me? I ditched custom command handling and automated everything using Latenode. Set up Discord webhooks that trigger on specific messages, then process commands through visual workflows. No more wrestling with Python event loops.

With Latenode, you create a webhook listener that catches Discord messages, checks for command patterns using simple filters, then sends responses back through Discord’s API. Bye-bye channel name restrictions and manual string parsing.

Best part? Super easy to extend. Connect your bot commands to databases, APIs, or other services by dragging components around. Way cleaner than hardcoding everything in Python.

Seriously, automating Discord bots this way saves massive debugging time. Check it out: https://latenode.com

Your channel name restriction is probably blocking the commands. The bot only works in channels named exactly ‘commands’ - if you’re testing somewhere else, it’ll just ignore everything. I hit this same issue with my guild bot. The channel check runs before command parsing, so even valid commands get dropped in the wrong channel. Comment out the if msg.channel.name == 'commands': line and test your command anywhere. Once it works, add the restriction back. Also, ‘!info’ in msg.content will match anywhere in the message, not just at the start - that might cause weird triggers down the road.