1
Fork 0
mirror of https://github.com/wlinator/luminara.git synced 2024-10-02 18:23:12 +00:00

feat: Update admin commands

This commit is contained in:
wlinator 2024-09-01 08:14:43 -04:00
parent a526183074
commit 7c286a4f82
4 changed files with 84 additions and 5 deletions

View file

@ -13,7 +13,22 @@ class Sql(commands.Cog):
@commands.command(name="sqlselect", aliases=["sqls"])
@commands.is_owner()
async def select_cmd(self, ctx: commands.Context[commands.Bot], *, query: str) -> None:
async def select_cmd(
self,
ctx: commands.Context[commands.Bot],
*,
query: str,
) -> None:
"""
Execute a SQL SELECT query.
Parameters
----------
ctx : commands.Context[commands.Bot]
The context of the command.
query : str
The SQL query to execute.
"""
if query.lower().startswith("select "):
query = query[7:]
@ -45,7 +60,22 @@ class Sql(commands.Cog):
@commands.command(name="sqlinject", aliases=["sqli"])
@commands.is_owner()
async def inject_cmd(self, ctx: commands.Context[commands.Bot], *, query: str) -> None:
async def inject_cmd(
self,
ctx: commands.Context[commands.Bot],
*,
query: str,
) -> None:
"""
Execute a SQL INJECT query.
Parameters
----------
ctx : commands.Context[commands.Bot]
The context of the command.
query : str
The SQL query to execute.
"""
try:
database.execute_query(query)
embed = Builder.create_embed(

View file

@ -12,7 +12,24 @@ class Award(commands.Cog):
@commands.command(name="award")
@commands.is_owner()
async def award_command(self, ctx: commands.Context[commands.Bot], user: discord.User, amount: int) -> None:
async def award_command(
self,
ctx: commands.Context[commands.Bot],
user: discord.User,
amount: int,
) -> None:
"""
Award a user with a specified amount of currency.
Parameters
----------
ctx : commands.Context[commands.Bot]
The context of the command.
user : discord.User
The user to award.
amount : int
The amount of currency to award.
"""
curr = Currency(user.id)
curr.add_balance(amount)
curr.push()

View file

@ -19,6 +19,17 @@ class Blacklist(commands.Cog):
*,
reason: str | None = None,
) -> None:
"""
Blacklist a user from the bot.
Parameters
----------
ctx : commands.Context[commands.Bot]
The context of the command.
user : discord.User
The user to blacklist.
reason : str | None, optional
"""
blacklist_service = BlacklistUserService(user.id)
blacklist_service.add_to_blacklist(reason)

View file

@ -17,13 +17,22 @@ class Dev(commands.Cog):
@dev.command(
name="sync_tree",
aliases=["sync"],
usage="sync_tree [guild]",
)
async def sync(
self,
ctx: commands.Context[commands.Bot],
guild: discord.Guild | None = None,
) -> None:
"""
Sync the bot's tree to the specified guild.
Parameters
----------
ctx : commands.Context[commands.Bot]
The context of the command.
guild : discord.Guild | None, optional
The guild to sync the tree to, by default None.
"""
if guild:
self.bot.tree.copy_global_to(guild=guild)
@ -31,12 +40,24 @@ class Dev(commands.Cog):
await ctx.send(content=CONST.STRINGS["dev_sync_tree"])
@dev.command(name="clear_tree", aliases=["clear"])
@dev.command(
name="clear_tree",
aliases=["clear"],
)
async def sync_global(
self,
ctx: commands.Context[commands.Bot],
guild: discord.Guild | None = None,
) -> None:
"""
Clear the bot's tree for the specified guild.
Parameters
----------
ctx : commands.Context[commands.Bot]
The context of the command.
guild : discord.Guild | None, optional
"""
self.bot.tree.clear_commands(guild=guild)
await ctx.send(content=CONST.STRINGS["dev_clear_tree"])