(data): Adding support for premium currency.

This commit is contained in:
JetRaidz
2022-02-19 21:00:08 +13:00
parent fde070a052
commit df032a8f78
2 changed files with 17 additions and 3 deletions

View File

@@ -14,7 +14,7 @@ meta = RowTable(
user_config = RowTable(
'user_config',
('userid', 'timezone', 'topgg_vote_reminder', 'avatar_hash'),
('userid', 'timezone', 'topgg_vote_reminder', 'avatar_hash', 'gems'),
'userid',
cache=TTLCache(5000, ttl=60*5)
)
@@ -120,6 +120,19 @@ def get_member_rank(guildid, userid, untracked):
return curs.fetchone() or (None, None)
@user_config.save_query
def set_gems(userid, amount):
with user_config.conn as conn:
cursor = conn.cursor()
cursor.execute(
"UPDATE user_config SET gems = %s WHERE userid = %s RETURNING *",
(amount, userid)
)
data = cursor.fetchone()
if data:
return user_config._make_rows(data)[0]
global_guild_blacklist = Table('global_guild_blacklist')
global_user_blacklist = Table('global_user_blacklist')
ignored_members = Table('ignored_members')

View File

@@ -42,9 +42,10 @@ CREATE TABLE global_guild_blacklist(
CREATE TABLE user_config(
userid BIGINT PRIMARY KEY,
timezone TEXT,
topgg_vote_reminder,
topgg_vote_reminder BOOLEAN,
avatar_hash TEXT,
API_timestamp BIGINT
API_timestamp BIGINT,
gems INTEGER DEFAULT 0
);
-- }}}