-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
526bb20
commit e29d626
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import json | ||
from CharmCord.globeHandler import get_globals | ||
|
||
|
||
async def getGlobalUserVar(args, context): | ||
all_vars = get_globals()[2] | ||
|
||
ag = args.split(";") | ||
user = ag[0].replace("<@", "").replace(">", "") | ||
var = ag[1] | ||
try: | ||
with open("variables.json", "r") as variables: | ||
total = json.load(variables) | ||
return total[f"{user}_{var}"] | ||
except KeyError: | ||
with open("variables.json", "r") as variables: | ||
total = json.load(variables) | ||
with open("variables.json", "w") as variables: | ||
total.update({f"{user}_{var}": all_vars[var]}) | ||
json.dump(total, variables) | ||
return all_vars[var] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import json | ||
|
||
|
||
async def setGlobalUserVar(args, context): | ||
ag = args.split(";") | ||
user = ag[0].replace("<@", "").replace(">", "") | ||
var = ag[1] | ||
value = ag[2] | ||
with open("variables.json", "r") as variables: | ||
total = json.load(variables) | ||
with open("variables.json", "w") as variables: | ||
try: | ||
total.update({f"{user}_{var}": int(value)}) | ||
except: | ||
total.update({f"{user}_{var}": value}) | ||
json.dump(total, variables) | ||
return |