summaryrefslogtreecommitdiff
path: root/initialise_db.py
diff options
context:
space:
mode:
Diffstat (limited to 'initialise_db.py')
-rw-r--r--initialise_db.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/initialise_db.py b/initialise_db.py
index fc89ad9..92ae56c 100644
--- a/initialise_db.py
+++ b/initialise_db.py
@@ -17,8 +17,10 @@ with open("config.yaml", "r") as yamlfile:
config = yaml.load(yamlfile, Loader=yaml.CLoader)
print("Read config successful")
config = config
+intents = discord.Intents.default()
+intents.members = True
-client = discord.Client()
+client = discord.Client(intents=intents)
# Runs once bot has connected to discord
@@ -31,7 +33,7 @@ async def on_ready():
for guild in client.guilds:
if guild.id == config["discord_server_id"]:
print(f"{time_now}: {client.user} has joined {guild.name}!")
- # populate_users(guild.members)
+ await populate_users(guild.members)
# cur_exp = 0
# for i in range(10):
# print(f"level {i}: {cur_exp} exp")
@@ -40,11 +42,12 @@ async def on_ready():
# print(f"{cur_exp} + 5 * {(pow(i,2))} + {(50 * i)} + 100")
# cur_exp = cur_exp + 5 * pow(i, 2) + (50 * i) + 100
populate_levels()
- # populate_items()
+ populate_items()
-def populate_users(users: list):
- for member in guild.members:
+async def populate_users(members: list):
+ users = []
+ for member in members:
print(member)
print(member.display_name)
print(member.nick)
@@ -58,7 +61,7 @@ def populate_users(users: list):
)
)
mee6API = API(config["discord_server_id"])
- mee6_levels = mee6API.levels.get_leaderboard_page(0)
+ mee6_levels = await mee6API.levels.get_leaderboard_page(0)
for user in users:
for mee6_user in mee6_levels["players"]:
if mee6_user["username"] == user.username:
@@ -77,7 +80,7 @@ def populate_levels():
reward_currency *= 1.5
print(f"level {i}: {cur_exp} exp, {reward_currency} coins")
level = Level(level=i, exp_required=cur_exp, reward_currency=reward_currency)
- level.save()
+ level.save(force_insert=True)
print(f"{cur_exp} + 5 * {(pow(i,2))} + {(50 * i)} + 100")
cur_exp = cur_exp + 5 * pow(i, 2) + (50 * i) + 100