stop triggering cascade delete when changing settings
This commit is contained in:
parent
065ff678a8
commit
fac4fec25f
2 changed files with 6 additions and 4 deletions
|
@ -79,7 +79,7 @@ class Nomen(Bot):
|
||||||
return prefix
|
return prefix
|
||||||
|
|
||||||
async def set_guild_prefix(self, guild: Guild, 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
|
self.prefixes[guild.id] = prefix
|
||||||
|
|
||||||
async def start(self, *args, **kwargs):
|
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,))
|
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):
|
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()
|
await self.db.commit()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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`"
|
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()
|
await self.bot.db.commit()
|
||||||
|
|
||||||
@nomen.command(name="opt-in")
|
@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`"
|
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()
|
await self.bot.db.commit()
|
||||||
|
|
||||||
@group(invoke_without_command=True)
|
@group(invoke_without_command=True)
|
||||||
|
|
Loading…
Reference in a new issue