fix None type error
This commit is contained in:
parent
c12bcd68c2
commit
6a4c8b759a
|
@ -34,6 +34,7 @@ def send_chat(message):
|
||||||
|
|
||||||
# # # db stuff # # #
|
# # # db stuff # # #
|
||||||
def read_users_points(db, user_id):
|
def read_users_points(db, user_id):
|
||||||
|
"""Errors out if user doesn't exist."""
|
||||||
try:
|
try:
|
||||||
cursor = db.execute(
|
cursor = db.execute(
|
||||||
"SELECT points FROM points WHERE id = ?",
|
"SELECT points FROM points WHERE id = ?",
|
||||||
|
@ -46,12 +47,17 @@ def read_users_points(db, user_id):
|
||||||
|
|
||||||
|
|
||||||
def read_users_points_from_username(db, username):
|
def read_users_points_from_username(db, username):
|
||||||
|
"""Returns None if user doesn't exist, their points otherwise."""
|
||||||
try:
|
try:
|
||||||
cursor = db.execute(
|
cursor = db.execute(
|
||||||
"SELECT points FROM points WHERE name = ?",
|
"SELECT points FROM points WHERE name = ?",
|
||||||
(username,)
|
(username,)
|
||||||
)
|
)
|
||||||
return cursor.fetchone()[0]
|
points = cursor.fetchone()
|
||||||
|
if points is None:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return cursor.fetchone()[0]
|
||||||
except Error as e:
|
except Error as e:
|
||||||
print("Error occured reading points from username:", e.args[0])
|
print("Error occured reading points from username:", e.args[0])
|
||||||
print("To user:", username)
|
print("To user:", username)
|
||||||
|
|
Loading…
Reference in New Issue