add short helpers for getting/changing user settings
This commit is contained in:
parent
1573d0b046
commit
d868427fc6
1 changed files with 5 additions and 5 deletions
|
@ -90,11 +90,11 @@ class Nomen(Bot):
|
||||||
await super().close()
|
await super().close()
|
||||||
await self.db.close()
|
await self.db.close()
|
||||||
|
|
||||||
async def user_toggle(self, user_id, item):
|
async def get_setting(self, user_id, setting):
|
||||||
await self.db.execute(
|
return await self.db.fetch_singleton(f"SELECT {setting} FROM users WHERE user_id=?", (user_id,))
|
||||||
"REPLACE INTO users (user_id, {item}) VALUES(:user_id, iff((SELECT {item} FROM users WHERE user_id=:user_id)), 0, 1)",
|
|
||||||
{"user_id": user_id},
|
async def set_setting(self, user_id, setting, value: bool):
|
||||||
)
|
await self.db.execute(f"REPLACE INTO users (user_id, {setting}) VALUES(?, ?)", (user_id, value))
|
||||||
await self.db.commit()
|
await self.db.commit()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue