Skip to content
Permalink
Browse files
why is it always a string
  • Loading branch information
lycette2 committed Nov 12, 2020
1 parent 0b85629 commit 66bc14fe23bd29d84f8cbf107b6495761802f7c5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
BIN +0 Bytes (100%) .vs/Chatbot/v16/.suo
Binary file not shown.
BIN +0 Bytes (100%) .vs/slnx.sqlite
Binary file not shown.
@@ -5,10 +5,12 @@ import os
import random
import discord
import steam
import requests
from steam.webapi import WebAPI
from dotenv import load_dotenv #only used so we can have the token outside of the source code
from steam.steamid import *


load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
GUILD = os.getenv('DISCORD_GUILD')
@@ -21,8 +23,29 @@ api = WebAPI(key=steamApiKey)

steamID= "STEAM_0:0:73873614" #this is Emily's steamID which is useful to use as a stub when testing
def steamAchievementPercentages(steamID, gameID): #Emily - as you can see it's going well
pass
achieveList= requests.get("http://api.steampowered.com/ISteamUserStats/GetPlayerAchievements/v0001/?appid=" +gameID+ "&key=" +steamApiKey+ "&steamid=" +steamID)
totalAchieves = 1
achievesCompleted=0
print (len(achieveList.text))
achieveList = achieveList.text
achieveList = achieveList.replace("\"", " ")
achieveList = achieveList.replace("{", "\"")
achieveList = achieveList.replace("}", "\"")
achieveList = achieveList.strip("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz,:0123456789\" ")
print (achieveList)
for achieve in achieveList:
print (achieve)
if "\"achieved\":0" in achieve:
totalAchieves = totalAchieves + 1
if "\"achieved\":1" in achieve:
achievesCompleted = achievesCompleted + 1
totalAchieves = totalAchieves + 1
percentage= round ((achievesCompleted/totalAchieves)*100, 2)
print(achievesCompleted)
print(totalAchieves)
return percentage

#print (steamAchievementPercentages("76561198108012956", "582010"))
#==================END OF DEFINITIONS===================


0 comments on commit 66bc14f

Please sign in to comment.