Skip to content

Instantly share code, notes, and snippets.

@4Kaylum
Created September 6, 2019 22:24
Show Gist options
  • Select an option

  • Save 4Kaylum/6e7f0ae03c2d97d2bd32577f7aa0bb56 to your computer and use it in GitHub Desktop.

Select an option

Save 4Kaylum/6e7f0ae03c2d97d2bd32577f7aa0bb56 to your computer and use it in GitHub Desktop.
A cog that gets a person at rank N on the Mee6 leaderboards
"""Gets a member at the Nth place on Mee6's leaderboard"""
from discord.ext import commands
from cogs import utils
class Mee6Ranking(utils.Cog):
def __init__(self, bot:utils.CustomBot):
super().__init__(bot)
@commands.command()
async def mee6rank(self, ctx:commands.Context, rank:int):
"""Gives you the user at rank N on Mee6"""
url = f"https://mee6.xyz/api/plugins/levels/leaderboard/{ctx.guild.id}"
params = {
"page": rank // 100
}
async with self.bot.session.get(url, params=params) as r:
data = await r.json()
index = (rank % 100) - 1
user_id = int(data['players'][index]['id'])
user = ctx.guild.get_member(user_id)
if user is None:
await ctx.send(f"The user in {rank}th place has left the server.")
else:
await ctx.send(f"The user in {rank}th place is {user.mention}!")
def setup(bot):
x = Mee6Ranking(bot)
bot.add_cog(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment