@client.listen("on_message")
async def on_message(message):
userid = message.author.id
Guild = message.guild
Member = message.guild.owner
if Member.mentioned_in(message.content):
cursor = ownerpingtime.cursor()
cursor.execute("SELECT ownerpingtime FROM ownerpingtime WHERE client_id = " + str(userid))
ownerpingtime.commit()
alldata = cursor.fetchall()
timedid : int = alldata[0][0]
timetillban : int = 5 - int(timedid)
if timedid == 1:
await message.delete()
await message.reply(f"{message.author}#{message.author.discriminator} ping this server owner `{timedid}` time, you have `{timetillban}` till you will be banned")
if timedid > 1 and timedid < 10:
await message.delete()
await message.reply(f"{message.author}#{message.author.discriminator} ping this server owner `{timedid}` times, you have `{timetillban}` till you will be banned")
if timedid == 10:
await message.delete()
await message.send(f"{message.author}#{message.author.discriminator} has banned from {Guild} by pinged guild owner 10 times")
await message.author.send(f"You have banned from {Guild} by pinged guild owner 10 times")
这就是错误
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\blabla\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\blabla\Desktop\All Things\Code File\Python\Discord.py\MineHardcore.py", line 168, in on_message
if Member.mentioned_in(message.content):
AttributeError: 'NoneType' object has no attribute 'mentioned_in'