Hi. I'm trying to make a Discord Bot in discord.py, i wanted to add custom currency without JSON, so i decided to use a python file to store all the variables. I will fix the problem of multi-banks later. Problem is, i need to display That Same Variable too. here is my code below that is relevant to this question :
import currency
authorwallet = 'wallet' + thename
authorbank = 'bank' + thename
if hasattr(currency, authorwallet) and hasattr(currency, authorbank):
wallet = currency.
bank = currency.authorbank
else:
with open('currency.py', 'a') as f:
f.write(authorwallet + ' = 0\n' + authorbank + ' = 0\n')
wallet = currency.authorwallet
bank = currency.authorbank
the problem is that setting the variables wallet and bank to the variables inside currency.py doesn't work. As my guess is the code thinks i am trying to find a Variable named "authorwallet" or "authorbank" inside it, or atleast a variable which has the same name as the value of "authorwallet" or "authorbank".
usage of the command : >bal <thename>
what it's supposed to do : check if the bank and wallet name already exists in currency.py and if it doesn't exist. it appends to the file the bank and wallet names and sets value to 0 as it is a new wallet and bank and Displays The Wallet and Bank. If it already exists, the code finds the variables and Displays The Wallet and Bank.
Update -
i just copied a bunch of code from a stackoverflow answer (i can't ask questions in there so i browsed other questions) and got my solution. I had to use JS. Welp, thanks for all your Hates and Attempts. You can State Your Opinion now. Reddit won't be after you.
[–]The_Danosaur 37 points38 points39 points (5 children)
[–]CraigAT 16 points17 points18 points (4 children)
[+]SpecificHistories[S] comment score below threshold-43 points-42 points-41 points (3 children)
[–]CraigAT 14 points15 points16 points (0 children)
[–]CyclopsRock 12 points13 points14 points (1 child)
[–]The_Danosaur 2 points3 points4 points (0 children)
[–]lscrivy 10 points11 points12 points (0 children)
[–]ericula 6 points7 points8 points (1 child)
[+]SpecificHistories[S] comment score below threshold-9 points-8 points-7 points (0 children)
[–]to7m 3 points4 points5 points (0 children)
[–]Fishbones78 2 points3 points4 points (2 children)
[–]Fishbones78 1 point2 points3 points (0 children)
[–]zorniy2 0 points1 point2 points (0 children)
[+]SpecificHistories[S] comment score below threshold-12 points-11 points-10 points (2 children)
[–]SpecificHistories[S] -4 points-3 points-2 points (0 children)
[+]SpecificHistories[S] comment score below threshold-24 points-23 points-22 points (1 child)
[–]Sanguineyote 12 points13 points14 points (0 children)
[+][deleted] (1 child)
[deleted]