added team owner id to database

This commit is contained in:
Sakimori 2020-12-26 21:53:46 -05:00
parent 663fc6c3f6
commit e369099544
3 changed files with 9 additions and 8 deletions

View File

@ -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

View File

@ -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

View File

@ -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 == "👎":