implement settings command
This commit is contained in:
parent
2bdf4f3e25
commit
f3b40986be
1 changed files with 41 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Literal
|
||||||
|
|
||||||
|
import disnake
|
||||||
from disnake.ext.commands import Cog, group, guild_only
|
from disnake.ext.commands import Cog, group, guild_only
|
||||||
|
|
||||||
from .utils import confirm
|
from .utils import confirm
|
||||||
|
@ -108,3 +110,42 @@ You may want to `{ctx.clean_prefix}nomen export` first"""
|
||||||
|
|
||||||
await self.bot.db.execute("REPLACE INTO users (user_id, disabled) VALUES(?, 0)", (ctx.author.id,))
|
await self.bot.db.execute("REPLACE INTO users (user_id, disabled) VALUES(?, 0)", (ctx.author.id,))
|
||||||
await self.bot.db.commit()
|
await self.bot.db.commit()
|
||||||
|
|
||||||
|
@group(invoke_without_command=True)
|
||||||
|
async def settings(
|
||||||
|
self,
|
||||||
|
ctx,
|
||||||
|
setting: Literal["use-embed", "notify-self", "bots-notify"],
|
||||||
|
value: bool,
|
||||||
|
):
|
||||||
|
"""
|
||||||
|
Change settings for Nomen
|
||||||
|
|
||||||
|
Valid settings are:
|
||||||
|
- `use-embed`
|
||||||
|
- `notify-self`
|
||||||
|
- `bots-notify`
|
||||||
|
"""
|
||||||
|
setting_db = setting.replace("-", "_")
|
||||||
|
|
||||||
|
await ctx.bot.set_setting(ctx.author.id, setting_db, value)
|
||||||
|
await self.settings_list(ctx)
|
||||||
|
|
||||||
|
@settings.command(name="list")
|
||||||
|
async def settings_list(self, ctx):
|
||||||
|
"""
|
||||||
|
Print all of your current settings
|
||||||
|
"""
|
||||||
|
|
||||||
|
settings = await ctx.bot.db.execute_fetchall(
|
||||||
|
"SELECT use_embed, notify_self, bots_notify FROM users WHERE user_id=?", (ctx.author.id,)
|
||||||
|
)
|
||||||
|
|
||||||
|
settings = ["Yes" if v else "No" for v in settings[0]]
|
||||||
|
|
||||||
|
embed = disnake.Embed(title="Current Settings")
|
||||||
|
embed.add_field("Use Embeds in Notifications (`use-embed`)", settings[0], inline=False)
|
||||||
|
embed.add_field("Notify Self (`notify-self`)", settings[1], inline=False)
|
||||||
|
embed.add_field("Notifications from Bots (`bots-notify`)", settings[2], inline=False)
|
||||||
|
|
||||||
|
await ctx.send(embed=embed)
|
||||||
|
|
Loading…
Reference in a new issue