Discord Bot Command Not Responding

Help! My Discord bot isn’t working as expected.

I’ve set up a Discord bot with both slash commands and regular commands. The slash commands are working fine, but the regular commands aren’t responding at all. Specifically, when I type !dog, it should reply with ‘dog’, but nothing happens.

Here’s a simplified version of my code:

import discord
from discord.ext import commands

class MyClient(discord.Client):
    def __init__(self):
        super().__init__(intents=discord.Intents.default())
        self.tree = discord.app_commands.CommandTree(self)

    async def on_ready(self):
        print(f'{self.user} is online!')

client = MyClient()
bot = commands.Bot(command_prefix='!', intents=discord.Intents.all())

@bot.command()
async def cat(ctx):
    await ctx.send('meow')

@client.tree.command(name='hello')
async def greet(interaction: discord.Interaction):
    await interaction.response.send_message('Hi there!')

client.run('bot_token_here')

The console doesn’t show any errors, and the slash commands work fine. But the !cat command doesn’t do anything when I type it. What am I doing wrong? Any help would be really appreciated!

I’ve been through this exact headache before, mate. The problem isn’t just mixing client and bot classes - it’s also about event handling. Your bot isn’t processing message events properly.

Here’s what worked for me:

  1. Stick to commands.Bot as others suggested.
  2. Make sure you’ve enabled the message content intent.
  3. Add an on_message event handler to process commands.

Try this code:

intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='!', intents=intents)

@bot.event
async def on_message(message):
    await bot.process_commands(message)

@bot.command()
async def dog(ctx):
    await ctx.send('woof')

@bot.tree.command(name='hello')
async def greet(interaction: discord.Interaction):
    await interaction.response.send_message('Hi there!')

bot.run('your_token_here')

This should sort out both your regular and slash commands. Let me know if you need any more help!

I see the issue in your code. You’re mixing the discord.Client and commands.Bot classes, which is causing the problem. The regular commands aren’t working because you’re running the client instance, not the bot instance.

To fix this, you should use just one approach. Since you want both slash and regular commands, I’d suggest sticking with commands.Bot. Here’s a quick example of how to modify your code:

import discord
from discord.ext import commands

intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='!', intents=intents)

@bot.command()
async def cat(ctx):
    await ctx.send('meow')

@bot.tree.command(name='hello')
async def greet(interaction: discord.Interaction):
    await interaction.response.send_message('Hi there!')

bot.run('bot_token_here')

This should resolve your issue and allow both regular and slash commands to work properly.

yo man, i had the same issue. ur problem is mixing client n bot classes. stick with commands.Bot for both slash and regular commands. here’s a quick fix:

use intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix=‘!’, intents=intents)

then just use @bot for both command types. shoud work fine