Hello, I have 2 functions that save dictionaries into JSON files and load the JSON file and save it into a dictionary. Everything works fine until I try to get the value of something, i.e. my discord id which has stored a token. There is the code:
JSON file:
{‘1234567890’: “some token”}
Discord Interaction where I call the get_auth function:
async def balance(interaction: discord.Interaction):
if (token := await get_auth(interaction.user)) is None:
print(token)
print(await get_auth(interaction.user))
await interaction.response.send_message("You must login before using any command")
else:
await interaction.response.send_message(f"Your actual balance is: {Currency.balance(token)}<:rbx:1085598507764822016>")
load_auth function:
def load_auth():
with open("tokens.json","r") as json_file:
jsn = json.load(json_file)
dic = dict()
for token in jsn:
dic[token] = jsn[
token
]
json_file.close()
return dic
get_auth function:
async def get_auth(user: discord.User):
secondtry = load_auth()
return auth.get(user.id) or secondtry.get(user.id) or None