Ty Strong
Ty Strong

Reputation: 13

How do I make my discord bot respond when a specific user sends a message in the channel?

I want to have my discord bot respond every time a specific user sends a message in the chat. The code runs but nothing happens when that user sends a message.

This is what I have tried so far:

@client.event
async def on_message(message):
    if message.author == client.user:
        return
        
    if message.author.id == '546474118711869440':
        await message.channel.send('shhhhh')

Upvotes: 0

Views: 2504

Answers (1)

Duhon
Duhon

Reputation: 101

It's in a string. You have to put the user id as an int, so no quotes.

if message.author.id == 546474118711869440:
    await message.channel.send('shhhhh')

Upvotes: 1

Related Questions