add helper for toggling user settings

This commit is contained in:
Infinidoge 2024-12-28 03:56:53 -05:00
parent 3fed160303
commit 07b4679238
Signed by: Infinidoge
SSH key fingerprint: SHA256:GT2StvPQMMfFHyiiFJymQxfTG/z6EWLJ6NWItf5K5sA

View file

@ -89,6 +89,13 @@ 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):
await self.db.execute(
"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},
)
await self.db.commit()
bot = Nomen( bot = Nomen(
description="Keeper of Names", description="Keeper of Names",