diff --git a/nomen/main.py b/nomen/main.py index ff2d25d..626131f 100644 --- a/nomen/main.py +++ b/nomen/main.py @@ -79,7 +79,7 @@ class Nomen(Bot): return prefix async def set_guild_prefix(self, guild: Guild, prefix): - await self.db.execute("REPLACE INTO guilds (guild_id, prefix) VALUES(?, ?)", (guild.id, prefix)) + await self.db.execute("UPDATE guilds SET prefix = ? WHERE guild_id=?", (prefix, guild.id)) self.prefixes[guild.id] = prefix async def start(self, *args, **kwargs): @@ -94,7 +94,7 @@ class Nomen(Bot): return await self.db.fetch_singleton(f"SELECT {setting} FROM users WHERE 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.execute(f"UPDATE users SET {setting} = ? WHERE user_id=?", (value, user_id)) await self.db.commit() diff --git a/nomen/settings.py b/nomen/settings.py index fbe1d3d..3caf544 100644 --- a/nomen/settings.py +++ b/nomen/settings.py @@ -158,7 +158,8 @@ You may want to `{ctx.clean_prefix}nomen export` first""" f"You have now opted-out and will no longer trigger or receive notifications. To opt back in, run `{ctx.clean_prefix}nomen opt-in`" ) - await self.bot.db.execute("REPLACE INTO users (user_id, disabled) VALUES(?, 1)", (ctx.author.id,)) + await self.bot.db.execute("INSERT OR IGNORE INTO users (user_id) VALUES(?)", (ctx.author.id,)) + await self.bot.db.execute("UPDATE users SET disabled=1 WHERE user_id=?", (ctx.author.id,)) await self.bot.db.commit() @nomen.command(name="opt-in") @@ -177,7 +178,8 @@ You may want to `{ctx.clean_prefix}nomen export` first""" f"You have opted back in and will now trigger and receive notifications. To opt out, run `{ctx.clean_prefix}nomen opt-out`" ) - await self.bot.db.execute("REPLACE INTO users (user_id, disabled) VALUES(?, 0)", (ctx.author.id,)) + await self.bot.db.execute("INSERT OR IGNORE INTO users (user_id) VALUES(?)", (ctx.author.id,)) + await self.bot.db.execute("UPDATE users SET disabled=0 WHERE user_id=?", (ctx.author.id,)) await self.bot.db.commit() @group(invoke_without_command=True)