0
@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'

帮我。我打开了成员意图,我想检查是否在 message.content 中提到了公会所有者,然后我的机器人将其删除,发送通知,如果他们做了 10 次,那么我的机器人禁止他们(我使用了 Python MySQL 连接器)

4

1 回答 1

0

我不认为它正在检查 ping 所以你应该修改你的 if 语句并制作它if <@12345678901234> in message.content:并替换12345678901234为所有者 ID。

于 2021-09-08T08:28:17.987 回答