#πŸ”’ Need help telling discord.py bot to respond to "every message"

22 messages Β· Page 1 of 1 (latest)

karmic ledge
#

This is my very first coding project and I'd like to write a small bot that reacts to every message sent. So far I've only been able to figure out how to respond specifically to messages that just say "word".

This is what I have so far:

import discord

class Client(discord.Client):
async def on_ready(self):
print(f'Logged on as {self.user}!')

async def on_message(self, message):
    if message.author == self.user:
        return
    
    if message.content == 'word':
        await message.add_reaction('\U0001F525')

intents = discord.Intents.default()
intents.message_content = True

client = Client(intents=intents)
client.run('token')

I've tried various ways of rewriting

if message.content == 'word':

but the only comment that I've received was that it shouldn't be an if statement if i want to include EVERY message. Since I'm completely new to all this I don't know what the alternative could be.

TIA

crude rivetBOT
#

@karmic ledge

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

foggy bronze
#

Yeah no if

#

Just something like await message.channel.send("whatever")

karmic ledge
#

ok i tried:

import discord

class Client(discord.Client):
async def on_ready(self):
print(f'Logged on as {self.user}!')

async def on_message(self, message):
    if message.author == self.user:
        return
    
async def on_message():
    await message.channel.send("no idea what goes here sorry")
    await message.add_reaction('\U0001F525')

intents = discord.Intents.default()
intents.message_content = True

client = Client(intents=intents)
client.run('token')

and got this error message:

2026-02-16 06:03:19 ERROR discord.client Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\x\AppData\Roaming\Python\Python314\site-packages\discord\client.py", line 504, in _run_event
await coro(*args, **kwargs)
~~~~^^^^^^^^^^^^^^^^^
TypeError: Client.on_message() takes 0 positional arguments but 2 were given
2026-02-16 06:03:28 ERROR discord.client Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\x\AppData\Roaming\Python\Python314\site-packages\discord\client.py", line 504, in _run_event
await coro(*args, **kwargs)
~~~~^^^^^^^^^^^^^^^^^
TypeError: Client.on_message() takes 0 positional arguments but 2 were given
2026-02-16 06:03:32 ERROR discord.client Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\x\AppData\Roaming\Python\Python314\site-packages\discord\client.py", line 504, in _run_event
await coro(*args, **kwargs)
~~~~^^^^^^^^^^^^^^^^^
TypeError: Client.on_message() takes 0 positional arguments but 2 were given

Obviously I'm wrong about what's supposed to be in the brackets, but I am also probably wrong about other things too, I just don't know how.

foggy bronze
#

You need to add the arguments back into the on_message

foggy bronze
#

Self and message

#

Oh wait you have two events

#

Just put it all under the same one

#

Or one of them won't get recognised

karmic ledge
#

i'm almost there!

import discord

class Client(discord.Client):
async def on_ready(self):
print(f'Logged on as {self.user}!')

async def on_message(self, message):
    if message.author == self.user:
        return

    await message.add_reaction('\U0001F525')

intents = discord.Intents.default()
intents.message_content = True

client = Client(intents=intents)
client.run('token')

the only problem is that the bot both reacts to the comment with the emoji and then comments the emoji as well

granite ledge
#

It will ignore all bot messages and not just your bot

karmic ledge
granite ledge
karmic ledge
#
import discord

class Client(discord.Client):
    async def on_ready(self):
        print(f'Logged on as {self.user}!')

    async def on_message(self, message):
        if message.author.bot:
            return
        await message.add_reaction('\U0001F525')

intents = discord.Intents.default()
intents.message_content = True

client = Client(intents=intents)
client.run('token')
granite ledge
karmic ledge
#

WOW i don't know what happened because i was definitely saving but just to be sure i saved and restarted both visual studio and discord. it worked! thank you!

crude rivetBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.