Stats command

!stats <playername> complete

!stats <playername>, <weapon> incomplete
This commit is contained in:
2023-04-25 23:25:09 +02:00
parent 617eaa047d
commit c9bf475696
2 changed files with 48 additions and 1 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ class Roll(commands.Cog):
elif(rolled <= 50 and rolled > 25):
rating = "Meh"
elif(rolled <= 25 and rolled > 1):
rating = "Almost"
rating = "Bad"
elif(rolled == 1):
rating = "LOL"
+47
View File
@@ -0,0 +1,47 @@
from urllib import request
import discord
from discord.ext import commands
import requests
class Stats(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print("stats.py is ready")
@commands.command()
async def stats(self, ctx, pmessage="any player", message2="any weapon"):
message = pmessage
print(message)
print(message2)
if(message != "any player"):
if(message2 != "any weapon"):
message = message[:-1]
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 == message):
playerid = i
break
if (playerid != ""):
killstats = response[playerid]
botmessage = str(
"Playername: " + killstats['username'] + '\n' +
"Kills: " + str(killstats['kills']) + '\n' +
"Deaths " + str(killstats['deaths']) + '\n' +
"KD: " + str("{:0.2f}".format(killstats['kills']/killstats['deaths']))
)
else:
botmessage = "This player doesnt exist"
else:
botmessage = "No name given"
await ctx.send(botmessage)
async def setup(client):
await client.add_cog(Stats(client))