Discord.py: None of my commands work, but the bot still responds to things in on_message


I have a discord bot, and none of my commands work. Things in on_message do work, like the response you get when pinging the bot. A very strange issue, and I also tried removing the commands and re-declaring them, I tried bot.Bot and commands.Bot and nothing worked.

I was making a poll command, it did not display the poll command at all and the command did not work.
Only the info command and help command worked.


import discord
from discord.ext import commands
import platform
import distro
import logging

token = open("token.txt", "r").read()
#bot constructor
activity=discord.Game(name="I want my paycheck.")
intents = discord.Intents.all()
bot = commands.Bot(command_prefix='br!', intents=intents, status=discord.Status.dnd, activity=activity)
#Cache clearer cause discord.py
for command in bot.commands:

async def poll(ctx, question, *options):
    if len(options) < 2:
        await ctx.send('You need to provide at least two options.')
    if len(options) > 9:
        await ctx.send('You can provide up to nine options.')
    reactions = [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '][:len(options)]
    description = 'n'.join(f'{i+1}. {option}' for i, option in enumerate(options))
    embed = discord.Embed(title=question, description=description)
    message = await ctx.send(embed=embed)
    async for reaction in reactions:
        await message.add_reaction(reaction)
async def info(ctx):
    embed=discord.Embed(title="Bot info", description="Bot stats", color=0x2416e9)
    embed.add_field(name="Ping:", value=f"`{bot.latency}ms`", inline=True)
    embed.add_field(name="Python version", value=f"{platform.python_version()}", inline=True)
    embed.add_field(name="Linux distro", value=f"{distro.name(pretty=True)}", inline=True)
    await ctx.send(embed=embed)

async def on_ready():
    print(f'{bot.user.name} has connected to Discord!')

async def on_member_join(member):
    await member.create_dm()
    await member.dm_channel.send(
        f'Hi {member.name}, welcome to SteamOS!'

async def on_message(message):
    if message.author == bot.user:

    if bot.user.mentioned_in(message):
        await message.channel.send(f'***Do you mind?***')

Asked By: PieyIsAPie



I believe you need to add await bot.process_commands(message) to your on_message. I had a problem like this happen to me and that fixed it.

That would make your on_message look like this:

async def on_message(message):
    await bot.process_commands(message)
    if message.author == bot.user:

    if bot.user.mentioned_in(message):
        await message.channel.send(f'***Do you mind?***')
Answered By: MEGAsuperintinly
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.