Jinux.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:jinux-discord 作者: Atomicbeast101 项目源码 文件源码
def temp_channel_timeout():
    await dclient.wait_until_ready()
    while not dclient.is_closed:
        try:
            for channel in con_ex.execute("SELECT * FROM temp_channel WHERE date <= Datetime('{}');".format(
                    datetime.now().strftime('%Y-%m-%d %X'))):
                remove_channel = dclient.get_channel(channel[0])
                channel_name = channel[1]
                owner = discord.User(id=channel[2])
                await dclient.delete_channel(remove_channel)
                con_ex.execute('DELETE FROM temp_channel WHERE id={};'.format(channel[0]))
                con.commit()
                await dclient.send_message(owner, 'Channel `{}` has expired and has been removed!'.format(channel_name))
                log('TEMP_CHANNEL', 'Removed ID {} from database.'.format(channel[0]))
        except sqlite3.Error as ex:
            print('[{}]: {} - {}'.format(strftime("%b %d, %Y %X", localtime()), 'SQLITE',
                                         'Error when trying to select/delete data: ' + ex.args[0]))
            log_file.write('[{}]: {} - {}\n'.format(strftime("%b %d, %Y %X", localtime()), 'SQLITE',
                                                    'Error when trying to insert/delete data: ' + ex.args[0]))

        await asyncio.sleep(1)


# Auto remove temporary channel from database if an admin force removes it from the server
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号