Added first steam API command

This commit is contained in:
Robert 2020-01-07 02:41:08 +01:00
parent 82228b17eb
commit ca91cfddaf
7 changed files with 188 additions and 3 deletions

23
cogs/api/steam.py Normal file
View file

@ -0,0 +1,23 @@
import discord
from discord.ext import commands
from api import steam
class Steam(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command(name="SteamLevel", description="Finds the steam level of a user", usage="SteamLevel <Vanity URL>", aliases=["level"])
@commands.cooldown(1, 2)
async def SteamLevel(self, ctx, vanity_url):
level = steam.get_steam_level(vanity_url)
percentile = round(float(steam.get_steam_level_distribution(level)), 2)
if level is not None:
await ctx.send(f"{vanity_url} is level {level}! This makes him better than {percentile}% of Steam users!")
else:
await ctx.send(f"There is nobody named \"{vanity_url}\" on Steam, or their profile might be pivate.")
def setup(client):
client.add_cog(Steam(client))