Resadesker
Resadesker

Reputation: 79

Python discord bot warn specific person

I am doing a bot that will warn a person if the word in the message is blacklisted. The problem is that when the bot writes @person#tag it is not a mention, but just a text. How do I improve it? Here is my code:

badwords = ["lal", "sas"]
for word in badwords:
    if message.content.find(word) != -1:
        await message.channel.send("-warn @" + str(message.author)) 

Upvotes: 3

Views: 312

Answers (1)

Try:

badwords = ["lal", "sad"]
for word in badwords:
    if message.content.find(word) != -1:
        await message.channel.send(f"-warn {message.author.mention}") 

This makes it so that it mentions the author who sent the message

Upvotes: 4

Related Questions