#python-3.x
Вопрос:
@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:UsersblablaAppDataLocalProgramsPythonPython39libsite-packagesdiscordclient.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:UsersblablaDesktopAll ThingsCode FilePythonDiscord.pyMineHardcore.py", line 168, in on_message
if Member.mentioned_in(message.content):
AttributeError: 'NoneType' object has no attribute 'mentioned_in'
Помоги мне. Я включил намерения участников, и я хочу проверить, упоминается ли владелец гильдии в message.content, затем мой бот удалит его, отправит уведомление, и если они сделают это 10 раз, мой бот запретит их ( я использовал Python MySQL Connector )
Ответ №1:
Я не думаю, что это проверка на пинг, поэтому вам следует изменить свое заявление if, сделать его if <@12345678901234> in message.content:
и 12345678901234
заменить идентификатором владельца.