Bot commands not working in Discord server

I’m having issues with my Discord bot not responding to any commands I send. I’m pretty new to making bots and I can’t figure out what’s going wrong. The bot shows as online but when I type commands nothing happens. I’ve been looking at tutorials but still stuck. Any ideas what might be broken? Here’s my code:

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix='?')

@bot.event
async def on_ready():
    print('Bot is ready')

@bot.command()
async def assign_class(ctx, class_name):
    available_classes = ['MATH101', 'PHYS201', 'CHEM150', 'BIOL120', 'HIST101', 'ENG101', 'PSYC101', 'ECON201', 'ART101', 'MUS101']
    requested_class = class_name.upper()
    target_role = discord.utils.get(ctx.guild.roles, name=requested_class)
    
    if target_role is None or target_role.name not in available_classes:
        await ctx.send('That class role does not exist')
        return
    
    if target_role in ctx.author.roles:
        await ctx.send('You are already enrolled in this class')
    else:
        try:
            await ctx.author.add_roles(target_role)
            await ctx.send(f'Successfully enrolled in {target_role.name}')
        except discord.Forbidden:
            await ctx.send('Missing permissions to assign roles')

@bot.command()
async def clear_classes(ctx):
    available_classes = ['MATH101', 'PHYS201', 'CHEM150', 'BIOL120', 'HIST101', 'ENG101', 'PSYC101', 'ECON201', 'ART101', 'MUS101']
    removal_success = True
    
    for class_role in available_classes:
        role_obj = discord.utils.get(ctx.guild.roles, name=class_role)
        if role_obj in ctx.author.roles:
            try:
                await ctx.author.remove_roles(role_obj)
            except discord.Forbidden:
                await ctx.send('Cannot remove roles due to permissions')
                removal_success = False
                break
    
    if removal_success:
        await ctx.send('All class enrollments have been cleared')

bot.run('your_token_here')

you’re missing message intents! discord changed it, now bots need perms to read msgs. add intents = discord.Intents.default() and intents.message_content = True, then pass it to the Bot like commands.Bot(command_prefix='?', intents=intents) - that’s likely why ur cmds rnt working!

Debugging Discord bots manually sucks. I used to waste hours on permission issues and token problems.

Automating bot management changed everything for me. Instead of hunting down bugs and manually coding fixes, I set up automated workflows for command routing, error logging, and deployment.

I built a system that monitors bot health, manages permissions, and handles role assignments through visual workflows. No more guessing why commands fail or checking intents every time something breaks.

The automation catches problems early - logs every command attempt, tracks permission failures, and auto-restarts when needed. Way more reliable than doing it manually.

Check out automated Discord bot management: https://latenode.com

Your code looks fine, so here’s what’s probably going wrong. First, double-check your bot token in the bot.run() call - make sure it’s correct and formatted right. Second, verify the bot has read messages and manage roles permissions in your server settings. Also crucial - your bot’s role needs to be higher than the class roles you’re trying to assign. Even with manage roles enabled, it can’t touch roles above it in the hierarchy. I ran into this exact same thing when I started - turned out my bot role was positioned too low.

Had this exact problem last month and it drove me crazy for hours. Besides the intents issue TomDream mentioned, check if your bot has “Use Slash Commands” permission in your server settings. Sometimes the bot shows online but can’t process text commands without proper channel permissions. Also make sure the bot can see the channel you’re typing in - I once spent forever debugging code when the bot just didn’t have read access to that specific channel. Try re-inviting the bot with a fresh invite link that includes all permissions to rule out any setup gaps.