Dawgx
Dawgx

Reputation: 67

I'm trying to write a discord bot in python but my code is not working

I'm trying to code my first discord bot in python and I need a bit of help with this piece of code, keep in mind im new to python and I started learning about 2 weeks ago.

    @bot.event
async def on_message(message):
    content = message.content
    author = message.author
    if content == "example yes":
        bot.say("example @%s" % (author))

I want the bot to write "example2 @user" if a user says "example yes"

Upvotes: 0

Views: 71

Answers (1)

Patrick Haugh
Patrick Haugh

Reputation: 61014

You're not awaiting bot.say, and that's not how you mention a user (you use the User.mention attribute instead)

@bot.event
async def on_message(message):
    content = message.content
    author = message.author
    if content == "example yes":
        await bot.say("example {}".format(author.mention))

Upvotes: 1

Related Questions