From 07b4679238907565b42f4b08d1c93148fe9b6f21 Mon Sep 17 00:00:00 2001 From: Infinidoge Date: Sat, 28 Dec 2024 03:56:53 -0500 Subject: [PATCH] add helper for toggling user settings --- nomen/main.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nomen/main.py b/nomen/main.py index 241f258..214f69d 100644 --- a/nomen/main.py +++ b/nomen/main.py @@ -89,6 +89,13 @@ class Nomen(Bot): await super().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( description="Keeper of Names",