为什么这不会发送到频道?

时间:2020-07-06 14:59:12

标签: python discord.py

因此,我想将警告发送到用户设置的日志通道,但是它说NoneType没有属性send。但是,事情是 它是明确定义的!

编辑:我发现了原因。它选择的是它从数据库中获取的第一个查询,因此,如果来自其他服务器表的server_id位于另一个表的上方,则它将不起作用,因为您不在该服务器中


        cursor.execute("SELECT channel_id FROM logchannel")
        result1 = cursor.fetchone()
        if result1 is not None:
            channel_id = result1[0]
            channel1 = discord.utils.get(server.channels, id=channel_id)
        await ctx.send(f"{member.mention} was warned for {reason}")
        channel_id = result1[0]
        channel1 = discord.utils.get(server.channels, id=channel_id)
        await channel1.send(f"{member.mention} has been warned by {user.mention} for {reason}.")
        cursor.execute('SELECT warnings FROM warninglog WHERE user_id = %s AND guild_id = %s', (user_id, guild_id))
        result = cursor.fetchone()
        if result is None:
            warnings = 1
            cursor.execute('INSERT INTO warninglog (warnings, name, user_id, guild_id ) VALUES (%s, %s, %s, %s)',
                           (warnings, name, user_id, guild_id))
            conn.commit()


0 个答案:

没有答案