Discord Bot Command Not Working

I’m experiencing an issue with my Discord bot. Although the slash commands function properly, when I input “!dog”, I don’t get any response. My console doesn’t display any errors at all.

import discord
import random
from discord import app_commands
from discord.ext import commands

server_id = your_server_id

class MyBot(discord.Client):
    bot_instance = commands.Bot(command_prefix='!', intents=discord.Intents.all())

    def __init__(self):
        super().__init__(intents=discord.Intents.default())
        self.is_ready = False

    async def on_ready(self):
        await self.wait_until_ready()
        if not self.is_ready:
            await command_tree.sync(
                guild=discord.Object(id=server_id)
            )
            self.is_ready = True
        print(f"{self.user.name} is online.")

my_bot_instance = MyBot()
command_tree = app_commands.CommandTree(my_bot_instance)
intents_config = discord.Intents.all()
my_bot = commands.Bot(command_prefix="!", intents=intents_config)

@my_bot.command(name='dog')
async def dog_command(ctx):
    await ctx.send('dog')

@command_tree.command(guild=discord.Object(id=server_id),
                     name='test',
                     description='test command')
async def test_command(interaction: discord.Interaction):
    await interaction.response.send_message(f"Working!",
                                          ephemeral=True)

my_bot_instance.run('your_bot_token')

If anyone has a solution to this issue, I would really appreciate your help. Thanks for your attention.

bruh you’re running the wrong bot lmao. you decorated @my_bot.command but then call my_bot_instance.run() - those are two completely different objects. either move the dog command to my_bot_instance or just run my_bot instead

Yeah, it’s the dual bot setup like others said, but I hit this same issue switching from prefix to slash commands. Don’t try patching it - just rebuild the whole thing. Scrap the MyBot class and stick with standard commands.Bot. Put your slash command registration in the main bot’s on_ready event and run only one bot object. Mixing discord.Client with commands.Bot just creates a mess that breaks prefix commands. One bot instance handles both command types - keeps things clean and fixes the confusion that’s killing your setup.

Yeah, you’ve got two bot instances that aren’t communicating with each other.

Honestly though, all this manual Discord bot setup is a nightmare. I’ve been there - our team ran multiple bots for different server functions and it was constant headaches.

What fixed it for me? Automating the entire bot management process. Instead of wrestling with code every time I needed new commands or fixing instance conflicts, I built automated workflows that handle bot responses, command routing, and error handling.

The automation manages Discord API calls, handles multiple command types, and coordinates between different bots - no more manual setup mess. You won’t have to guess which instance is running or why commands aren’t registering.

Way cleaner than debugging bot code constantly. Plus you can set up automatic responses, scheduled messages, and complex command flows without touching Python.

Check out Latenode for this: https://latenode.com

You’ve got two separate bot instances but you’re mixing up their functionality. Your dog command is registered on my_bot, but my_bot_instance is what’s actually running. Since these are completely different objects, the running instance doesn’t know about the command you defined on the other bot. Just consolidate everything into one bot instance. Either define all commands on my_bot and run that, or move your prefix commands to my_bot_instance. Your slash commands work fine because you’re using the command tree with the correct running instance.

lol, you’re using the wrong bot instance! You defined the !dog command in my_bot, but you’re running my_bot_instance, which doesn’t have that command. Just switch the last line to my_bot.run('your_bot_token') and it should work!