Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
不协调Python重写-AFK_Python_Sqlite_Discord_Discord.py_Discord.py Rewrite - Fatal编程技术网

不协调Python重写-AFK

不协调Python重写-AFK,python,sqlite,discord,discord.py,discord.py-rewrite,Python,Sqlite,Discord,Discord.py,Discord.py Rewrite,所以,我使用SQLite3支持制作了一个AFK系统,它工作正常。但当我让我的朋友试着提及我时,它返回了一个错误 Traceback (most recent call last): File "C:\Python39\lib\site-packages\discord\client.py", line 333, in _run_event await coro(*args, **kwargs) File "C:\Users\Natalia\Deskt

所以,我使用SQLite3支持制作了一个AFK系统,它工作正常。但当我让我的朋友试着提及我时,它返回了一个错误

Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\discord\client.py", line 333, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\Natalia\Desktop\Files\Code\kap\main.py", line 752, in on_message
    if member_id in record:
TypeError: argument of type 'NoneType' is not iterable
代码

an = sqlite3.connect('afk.db')

a = an.cursor()

a.execute("""CREATE TABLE IF NOT EXISTS afk (
            user_id INTEGER,
            message TEXT
            )""")

async def remove_afk(user_id):
    with an:
        a.execute("""DELETE FROM afk WHERE user_id=:user_id""", {'user_id': user_id})

async def add_afk(user_id, message):
    with an:
        a.execute("INSERT INTO afk VALUES (:user_id, :message)", {'user_id': user_id, 'message': message})

async def afk_list(user_id):
    a.execute("SELECT * FROM afk WHERE user_id=:user_id", {'user_id': user_id})
    return a.fetchone()

async def get_afk_message(user_id):
    a.execute("SELECT message FROM afk WHERE user_id=:user_id",
        {'user_id': user_id})
    return a.fetchone()

@client.command()
async def afk(ctx, *, message="Dind't specify a message."):
    record = await afk_list(ctx.author.id)
    if record:
        await ctx.send(f"{ctx.author.mention}, You have a AFK running!")
        return
    else:
        await add_afk(ctx.author.id, message)
        await ctx.author.edit(nick=f'[AFK] {ctx.author.display_name}')
        await ctx.send(f"{ctx.author.mention}, You're now AFK.", delete_after=10)
        return

@client.event
async def on_message(message):
    
    if message.author.bot == True:
        pass
    else:
        
        user_id = message.author.id
        record = await afk_list(user_id)
        if record:
            await remove_afk(message.author.id)
            await message.author.edit(nick=message.author.display_name[6:]),
            await message.channel.send(f"{message.author.mention}, I've removed your afk.", delete_after=10)

        else:
            for member in message.mentions:
                member_id = member.id
                if member_id != message.author.id:
                    record = await afk_list(member_id)
                    if member_id in record:
                        afkmsg = await get_afk_message(user_id)

                        await message.channel.send("{0} Is AFK!\n{1}".format(member, afkmsg), delete_after=10)
    await client.process_commands(message)
请帮帮我,我真的不知道怎么修

AFK命令工作,添加和删除AFK工作,检查用户是否已检查AFK(不确定是否工作)