!stats upgrade to appearance and made start compare

This commit is contained in:
2023-04-27 00:46:14 +02:00
parent ff3504e070
commit 3202b9840f
2 changed files with 50 additions and 10 deletions
+44
View File
@@ -0,0 +1,44 @@
import discord
from discord.ext import commands
import requests
class Compare(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print("compare.py is ready")
@commands.command()
async def compare(self, ctx, *message):
listofplayers = []
for i in range(len(message)):
player = message[i].replace(",", "")
listofplayers.append(player)
listofplayerids = {}
for p in range(len(listofplayers)):
playername = listofplayers[p]
print(playername)
playerid = self.getplayerid(playername)
print(playerid)
listofplayerids[playerid] = playername
await ctx.send(listofplayerids)
def getplayerid(self, playername):
response = requests.get('https://tone.sleepycat.date/v2/client/players').json()
r = response.keys()
playerid = ""
for i in r:
p = response[i]['username']
if (p.lower() == playername.lower()):
playerid = i
break
return playerid
async def setup(client):
await client.add_cog(Compare(client))