【问题标题】:Python discord bot warn specific personPython不和谐机器人警告特定人
【发布时间】:2020-07-17 07:28:42
【问题描述】:

我正在做一个机器人,如果消息中的单词被列入黑名单,它会警告人们。 问题是当机器人写@person#tag 时,它不是提及,而只是一个文本。 我该如何改进它? 这是我的代码:

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

【问题讨论】:

    标签: python bots discord discord.py


    【解决方案1】:

    试试:

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

    这样会提到发送消息的作者

    【讨论】:

    • 随时@Resadesker
    猜你喜欢
    • 2021-10-30
    • 2021-05-27
    • 2021-07-15
    • 2021-03-29
    • 2021-07-11
    • 2021-03-25
    • 2018-08-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多