your problem is that you are using an old version/tutorial of discord.py
. Things like bot.send_message
are out of date and things like bot.kick
don't even exist.
The ideal code would be?:
infractions = {}
limit = 5
blacklist = ['old', 'version', 'of', 'discord', '.', 'py']
@bot.event
async def on_message(message):
content = message.content.replace(' ', '')
if any(word in content.lower() for word in blacklist):
id = message.author.id
infractions[id] = infractions.get(id, 0) + 1
if infractions[id] >= limit:
await message.author.kick()
else:
warning = f"{message.author.mention} this is your {infractions[id]} warning"
await message.channel.send(warning)
await bot.process_commands(message)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…