levels.py 文件源码

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

项目:csss-minion 作者: henrymzhao 项目源码 文件源码
def rank(self, ctx):
    if len(ctx.message.mentions) > 0:
      ctx.message.author = ctx.message.mentions[0]
    self.cur.execute('SELECT * FROM (SELECT *, row_number() OVER(ORDER BY exp DESC) FROM experience) AS filter WHERE filter.user_id={}'.format(ctx.message.author.id))
    res = list(self.cur.fetchone())
    self.cur.execute('SELECT count(*) from experience')
    totalUsers = self.cur.fetchone()[0]
    level = res[4]
    totalExperience = res[3]
    currentExperience = self.currentExp(level, totalExperience)
    rank = res[6]
    nextLevel = self.calcLevel(int(level))

    embed = discord.Embed(colour=discord.Colour(0x1d86c9))
    embed.set_author(name=ctx.message.author.name, icon_url=ctx.message.author.avatar_url)
    embed.set_footer(text="CSSS-Minion")
    embed.add_field(name="Rank", value="{}/{}".format(rank, totalUsers), inline=True)
    embed.add_field(name="Level", value=level, inline=True)
    embed.add_field(name="Experience", value="{} / {} XP [{} total]".format(int(currentExperience), int(nextLevel), int(totalExperience)), inline=True)
    await self.bot.say(embed=embed)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号