【发布时间】:2021-05-05 21:40:01
【问题描述】:
我有一个不和谐的垃圾邮件踢机器人,我想在你被禁止时发送私人消息。我试过这个:
@bot.event
async def on_message(message, ctx):
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 > 4 and not message.author.guild_permissions.administrator:
await message.guild.ban(message.author, reason="Spammer")
await message.channel.send(f"{message.author} kicked for spam.")
***ctx.author.send(message.author, "You were kicked for spam. You can rejoin in`60`seconds")***
await asyncio.sleep(30)
await message.guild.unban(message.author)
print(f"{message.author} kicked for spam.")
但它不起作用TypeError: on_message() missing 1 required positional argument: 'ctx'
问题是它也破坏了其余代码..所以现在根本不起作用。
关于如何向被禁止的人发送 dm有什么想法?
【问题讨论】:
标签: python discord discord.py