【发布时间】:2021-07-27 14:24:00
【问题描述】:
我有这个禁止垃圾邮件发送者的代码:
@bot.event
async def on_message(message):
counter = 0
with open("spam_detect.txt", "r+") as file:
for lines in file:
if lines.strip("\n") == str(message.author.id):
counter += 1
file.writelines(f"{str(message.author.id)}\n")
if counter > 5:
await message.guild.ban(message.author, reason="Spammer")
await asyncio.sleep(5)
await message.guild.unban(message.author)
await message.channel.send("Banned for spam")
print("banned")
用户被软禁,消息被删除,但我只能说Banned for spam..并且机器人擦除用户所做的一切,我不知道谁被禁止以及何时被禁止。我怎样才能说<USER> was banned for spam?
【问题讨论】:
-
像这样使用 f 字符串:
f"{message.author} was banned for spam."
标签: python discord discord.py