From f5498fc46cb0f1f3108cb075c006326273192e31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Tue, 19 Dec 2023 12:03:16 +0800 Subject: [PATCH] add alias & prefix --- bots/discord/slash/core.py | 53 +++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/bots/discord/slash/core.py b/bots/discord/slash/core.py index 8e320755..aca679a9 100644 --- a/bots/discord/slash/core.py +++ b/bots/discord/slash/core.py @@ -72,6 +72,57 @@ async def unban(ctx: discord.ApplicationContext, userid: str): await slash_parser(ctx, f"unban {userid}") +ali = client.create_group("alias", "Set custom command alias.") + + +@ali.command(description="Add custom command alias.") +@discord.option(name="alias", description="The custom alias.") +@discord.option(name="command", description="The command you want to refer to.") +async def add(ctx: discord.ApplicationContext, alias: str, command: str): + await slash_parser(ctx, f"add {alias} {command}") + + +@ali.command(description="Remove custom command alias.") +@discord.option(name="alias", description="The custom alias.") +async def remove(ctx: discord.ApplicationContext, alias: str): + await slash_parser(ctx, f"remove {alias}") + + +@ali.command(description="View custom command alias.") +async def list(ctx: discord.ApplicationContext): + await slash_parser(ctx, "list") + + +@ali.command(description="Reset custom command alias.") +async def reset(ctx: discord.ApplicationContext): + await slash_parser(ctx, "reset") + + +p = client.create_group("prefix", "Set custom command prefix.") + + +@p.command(description="Add custom command prefix.") +@discord.option(name="prefix", description="The custom prefix.") +async def add(ctx: discord.ApplicationContext, prefix: str): + await slash_parser(ctx, f"add {prefix}") + + +@p.command(description="Remove custom command prefix.") +@discord.option(name="prefix", description="The custom prefix.") +async def remove(ctx: discord.ApplicationContext, prefix: str): + await slash_parser(ctx, f"remove {prefix}") + + +@p.command(description="View custom command prefix.") +async def list(ctx: discord.ApplicationContext): + await slash_parser(ctx, "list") + + +@p.command(description="Reset custom command prefix.") +async def reset(ctx: discord.ApplicationContext): + await slash_parser(ctx, "reset") + + setup = client.create_group("setup", "Set up bot actions.") @@ -83,4 +134,4 @@ async def typing(ctx: discord.ApplicationContext): @setup.command(description="Set the time offset.") @discord.option(name="offset", description="The timezone offset.") async def offset(ctx: discord.ApplicationContext, offset: str): - await slash_parser(ctx, f"timeoffset {offset}") \ No newline at end of file + await slash_parser(ctx, f"timeoffset {offset}")