diff --git a/database.py b/database.py index 1db05e7..2595158 100644 --- a/database.py +++ b/database.py @@ -62,7 +62,8 @@ def initialcheck(): counter integer PRIMARY KEY, name text NOT NULL, team_json_string text NOT NULL, - timestamp text NOT NULL + timestamp text NOT NULL, + owner_id integer ); """ if conn is not None: @@ -190,14 +191,14 @@ def get_user_player(user): conn.close() return player -def save_team(name, team_json_string): +def save_team(name, team_json_string, user_id): conn = create_connection() try: if conn is not None: c = conn.cursor() - store_string = """ INSERT INTO teams(name, team_json_string, timestamp) - VALUES (?,?, ?) """ - c.execute(store_string, (re.sub('[^A-Za-z0-9 ]+', '', name), team_json_string, datetime.datetime.now(datetime.timezone.utc))) #this regex removes all non-standard characters + store_string = """ INSERT INTO teams(name, team_json_string, timestamp, owner_id) + VALUES (?,?, ?, ?) """ + c.execute(store_string, (re.sub('[^A-Za-z0-9 ]+', '', name), team_json_string, datetime.datetime.now(datetime.timezone.utc), user_id)) #this regex removes all non-standard characters conn.commit() conn.close() return True diff --git a/games.py b/games.py index 8e85366..81ea9cb 100644 --- a/games.py +++ b/games.py @@ -479,11 +479,11 @@ def get_team(name): # except: #return None -def save_team(this_team): +def save_team(this_team, user_id): try: this_team.prepare_for_save() team_json_string = jsonpickle.encode(this_team, keys=True) - db.save_team(this_team.name, team_json_string) + db.save_team(this_team.name, team_json_string, user_id) return True except: return None diff --git a/the_prestige.py b/the_prestige.py index b9427aa..9f188d4 100644 --- a/the_prestige.py +++ b/the_prestige.py @@ -573,7 +573,7 @@ async def save_team_batch(message, command): react, user = await client.wait_for('reaction_add', timeout=20.0, check=react_check) if react.emoji == "👍": await message.channel.send("You got it, chief. Saving now.") - games.save_team(newteam) + games.save_team(newteam, message.author.id) await message.channel.send("Saved! Thank you for flying Air Matteo. We hope you had a pleasant data entry.") return elif react.emoji == "👎":