简体   繁体   English

Python discord 机器人警告特定人员

[英]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.问题是当机器人写@person#tag 时,它不是提及,而只是一个文本。 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)) 

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这使得它提到了发送消息的作者

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 让 Discord 机器人 DM 成为特定的人 - Make a Discord bot DM a specific person Python中的Discord Bot-我试图从具有特定角色的所有人中随机挑选一个人 - Discord Bot in Python - Im trying to pick a random person from all the people with a specific role 将机器人创建的 txt 文件发送给个人或频道 discord.python - Sending a bot created txt file to a person or to a channel discord python Bot Discord python仅删除一个人的消息 - Bot Discord python deleting message only of one person Discord Bot Python - 向特定频道发送消息 - Discord Bot Python - Send message to specific channel 有没有办法对 discord 机器人进行编程,以便在特定人员发送消息时发送消息或添加反应? - Is there a way to program a discord bot to send a message or add a reaction whenever a specific person sends a message? 如何让我的 Discord 机器人提及频道中的特定人员? - How can i make my Discord bot mention a specific person in the channel? 我怎样才能让我的 discord 机器人在键入时提到特定的人? - How can I make it so my discord bot mentions a specific person when they type? 让我的 Discord 机器人响应某个人 - Getting my Discord Bot to Respond to a Certain Person 如何在特定频道中允许特定消息 discord bot python - how to allow specific messages discord bot python in specific channels
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM