aboutsummaryrefslogtreecommitdiff
path: root/cogs/src.py
diff options
context:
space:
mode:
authorThomas Voss <57815710+Mango0x45@users.noreply.github.com>2021-02-22 01:46:59 +0000
committerGitHub <noreply@github.com>2021-02-22 01:46:59 +0000
commita80f7aad3bfb03fc82d2fb594a4ec9210c2e7213 (patch)
tree7d68580a9b288134adae17bf2bb1b52bcc383464 /cogs/src.py
parente68c6ce13a945aa469a479eab90289c3d467b4d8 (diff)
parent2b672d4a9914d813dc20a4dc940ae0c6c8b79501 (diff)
downloadsteve-bot-a80f7aad3bfb03fc82d2fb594a4ec9210c2e7213.tar
steve-bot-a80f7aad3bfb03fc82d2fb594a4ec9210c2e7213.tar.gz
steve-bot-a80f7aad3bfb03fc82d2fb594a4ec9210c2e7213.tar.bz2
steve-bot-a80f7aad3bfb03fc82d2fb594a4ec9210c2e7213.tar.lz
steve-bot-a80f7aad3bfb03fc82d2fb594a4ec9210c2e7213.tar.xz
steve-bot-a80f7aad3bfb03fc82d2fb594a4ec9210c2e7213.tar.zst
steve-bot-a80f7aad3bfb03fc82d2fb594a4ec9210c2e7213.zip
Merge pull request #44 from randomidiot13/patch-1
Add verified command
Diffstat (limited to 'cogs/src.py')
-rwxr-xr-xcogs/src.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/cogs/src.py b/cogs/src.py
index 8419efb..72ec722 100755
--- a/cogs/src.py
+++ b/cogs/src.py
@@ -331,6 +331,43 @@ async def verifyNew(self, apiKey=None, userID=None):
else:
await member.remove_roles(RunneRole)
+async def verifiedCount(self, ctx, modName):
+ head = {
+ "Accept": "application/json",
+ "User-Agent": "mcbeDiscordBot/1.0"
+ }
+
+ r = requests.get(
+ f"https://www.speedrun.com/api/v1/users/{modName}",
+ headers=head
+ )
+ if r.status_code != 200:
+ await ctx.send(f"Could not find user {modName}")
+ return
+ try:
+ modID = r.json()['data']['id']
+ except:
+ await ctx.send("Something went wrong")
+ return
+
+ hold = []
+ temp = requests.get(
+ f"https://www.speedrun.com/api/v1/runs?examiner={modID}&max=200",
+ headers=head)
+ while True:
+ if temp.status_code != 200:
+ await ctx.send("Something went wrong")
+ return
+ temp_json = temp.json()
+ hold.extend(temp_json['data'])
+ if 'pagination' not in temp_json or temp_json['pagination']['size'] < 200:
+ break
+ temp = requests.get(
+ {item['rel']: item['uri']
+ for item in temp_json['pagination']['links']}['next'],
+ headers=head)
+
+ await ctx.send(f"{modName} has verified {len(hold)} runs")
class Src(commands.Cog):
def __init__(self, bot):
@@ -401,6 +438,14 @@ class Src(commands.Cog):
userID = ctx.message.author.id
await verifyNew(self, apiKey, userID)
+ @commands.command()
+ async def verified(self, ctx, modName=None):
+ async with ctx.typing():
+ if modName is None:
+ await ctx.send("Please supply a moderator to view stats of")
+ return
+ await verifiedCount(self, ctx, modName)
+
@tasks.loop(minutes=10.0)
async def checker(self):
data = json.loads(Path("./api_keys.json").read_text())