Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
OasisAkari committed Dec 20, 2023
2 parents 21e9da9 + 307940c commit d8e6733
Show file tree
Hide file tree
Showing 22 changed files with 130 additions and 104 deletions.
8 changes: 4 additions & 4 deletions bots/discord/slash/arcaea.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@
arcaea = client.create_group("arcaea", "Queries about Arcaea.")


@arcaea.command(description="Get the latest version of game apk.")
@arcaea.command(name="download", description="Get the latest version of game apk.")
async def download(ctx: discord.ApplicationContext):
await slash_parser(ctx, "download")


@arcaea.command(description="Random a song.")
@arcaea.command(name="random", description="Random a song.")
async def random(ctx: discord.ApplicationContext):
await slash_parser(ctx, "random")


rank = arcaea.create_subgroup("rank", "View the current daily rank of Arcaea songs.")


@rank.command(description="View the current rank of the free packs.")
@rank.command(name="free", description="View the current rank of the free packs.")
async def free(ctx: discord.ApplicationContext):
await slash_parser(ctx, "rank free")


@rank.command(description="View the current rank of the paid packs.")
@rank.command(name="paid", description="View the current rank of the paid packs.")
async def paid(ctx: discord.ApplicationContext):
await slash_parser(ctx, "rank paid")
2 changes: 1 addition & 1 deletion bots/discord/slash/ask.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from bots.discord.slash_parser import slash_parser


@client.slash_command(description="Answer your question via ChatGPT.")
@client.slash_command(name="ask", description="Answer your question via ChatGPT.")
@discord.option(name="question", description="Ask ChatGPT.")
async def ask(ctx: discord.ApplicationContext, question: str):
await slash_parser(ctx, question)
2 changes: 1 addition & 1 deletion bots/discord/slash/bugtracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async def auto_search(ctx: discord.AutocompleteContext):
return ['BDS-', 'MCPE-', 'MCD-', 'MCL-', 'MCLG-', 'REALMS-', 'MC-', 'WEB-']


@client.command(description="Query the corresponding ticket on Mojira.")
@client.command(name="bugtracker", description="Query the corresponding ticket on Mojira.")
@discord.option(name="mojiraid", autocomplete=auto_search)
async def bugtracker(ctx: discord.ApplicationContext, mojiraid: str):
await slash_parser(ctx, mojiraid)
2 changes: 1 addition & 1 deletion bots/discord/slash/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async def auto_complete(ctx: discord.AutocompleteContext):
return ['#123456', 'rgb(12,34,56)', 'hsl(123,45%,67%)']


@client.slash_command(description="Get color information.")
@client.slash_command(name="color", description="Get color information.")
@discord.option(name="color", default="", autocomplete=auto_complete,
description="Color information. Support for Hex, RGB, HSL color code, or name in CSS and Material Design.")
async def color(ctx: discord.ApplicationContext, color: str):
Expand Down
113 changes: 83 additions & 30 deletions bots/discord/slash/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,84 @@

from bots.discord.client import client
from bots.discord.slash_parser import slash_parser
from core.loader import ModulesManager
from core.utils.i18n import get_available_locales

@client.slash_command(description="View details of a module.")
@discord.option(name="module", default="", description="The module you want to know about.")
async def help(ctx: discord.ApplicationContext, module: str):
await slash_parser(ctx, module)
async def auto_get_module_list(ctx: discord.AutocompleteContext):
module_list = ModulesManager.return_modules_list()
module_ = []
for x in module_list:
if x[0] == '_':
continue
if module_list[x].required_superuser or module_list[x].required_base_superuser:
continue
module_.append(module_list[x])
return module_


async def auto_get_lang(ctx: discord.AutocompleteContext):
if not ctx.options["lang"]:
return get_available_locales()


@client.slash_command(description="Set the bot running languages.")
@discord.option(name="lang", default="", description="Supported language codes.")
@client.slash_command(name="locale", description="Set the bot running languages.")
@discord.option(name="lang", default="", description="Supported language codes.", autocomplete=auto_get_lang)
async def locale(ctx: discord.ApplicationContext, lang: str):
await slash_parser(ctx, lang)


@client.slash_command(description="Make the bot stop sending message.")
@client.slash_command(name="mute", description="Make the bot stop sending message.")
async def mute(ctx: discord.ApplicationContext):
await slash_parser(ctx, "")


@client.slash_command(description="Get bot status.")
@client.slash_command(name="ping", description="Get bot status.")
async def ping(ctx: discord.ApplicationContext):
await slash_parser(ctx, "")


@client.slash_command(description="Get the number of petals in the current channel.")
@client.slash_command(name="petal", description="Get the number of petals in the current channel.")
async def petal(ctx: discord.ApplicationContext):
await slash_parser(ctx, "")


@client.slash_command(description="View bot version.")
@client.slash_command(name="version", description="View bot version.")
async def version(ctx: discord.ApplicationContext):
await slash_parser(ctx, "")


@client.slash_command(description="Get the ID of the user account that sent the command inside the bot.")
@client.slash_command(name="whoami", description="Get the ID of the user account that sent the command inside the bot.")
async def whoami(ctx: discord.ApplicationContext):
await slash_parser(ctx, "")


admin = client.create_group("admin", "Commands available to bot administrators.")


@admin.command(description="Set members as bot administrators.")
@admin.command(name="add", description="Set members as bot administrators.")
@discord.option(name="userid", description="The user ID.")
async def add(ctx: discord.ApplicationContext, userid: str):
await slash_parser(ctx, f"add {userid}")


@admin.command(description="Remove bot administrator from member.")
@admin.command(name="remove", description="Remove bot administrator from member.")
@discord.option(name="userid", description="The user ID.")
async def remove(ctx: discord.ApplicationContext, userid: str):
await slash_parser(ctx, f"remove {userid}")


@admin.command(description="View all bot administrators.")
async def list(ctx: discord.ApplicationContext):
@admin.command(name="list", description="View all bot administrators.")
async def lst(ctx: discord.ApplicationContext):
await slash_parser(ctx, "list")


@admin.command(description="Limit someone to use bot in the channel.")
@admin.command(name="ban", description="Limit someone to use bot in the channel.")
@discord.option(name="userid", description="The user ID.")
async def ban(ctx: discord.ApplicationContext, userid: str):
await slash_parser(ctx, f"ban {userid}")


@admin.command(description="Remove limit someone to use bot in the channel.")
@admin.command(name="unban", description="Remove limit someone to use bot in the channel.")
@discord.option(name="userid", description="The user ID.")
async def unban(ctx: discord.ApplicationContext, userid: str):
await slash_parser(ctx, f"unban {userid}")
Expand All @@ -75,63 +88,103 @@ async def unban(ctx: discord.ApplicationContext, userid: str):
ali = client.create_group("alias", "Set custom command alias.")


@ali.command(description="Add custom command alias.")
@ali.command(name="add", 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.")
@ali.command(name="remove", 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(name="list", description="View custom command alias.")
@discord.option(name="legacy", choices=['false', 'true'], description="Whether to use legacy mode.")
async def lst(ctx: discord.ApplicationContext, legacy: str):
legacy = "legacy" if legacy == "true" else ""
await slash_parser(ctx, f"list {legacy}")


@ali.command(description="Reset custom command alias.")
@ali.command(name="reset", description="Reset custom command alias.")
async def reset(ctx: discord.ApplicationContext):
await slash_parser(ctx, "reset")


hlp = client.create_group("help", "Get bot help.")


@hlp.command(name="list", description="View help list.")
@discord.option(name="legacy", choices=['false', 'true'], description="Whether to use legacy mode.")
async def lst(ctx: discord.ApplicationContext, legacy: str):
legacy = "legacy" if legacy == "true" else ""
await slash_parser(ctx, legacy)


@hlp.command(name="detail", description="View details of a module.")
@discord.option(name="module", description="The module you want to know about.", autocomplete=auto_get_module_list)
async def detail(ctx: discord.ApplicationContext, module: str):
await slash_parser(ctx, module)


m = client.create_group("module", "Set about modules.")


@m.command(name="enable", description="Enable module(s).")
@discord.option(name="module", description="The modules you want to enable.", autocomplete=auto_get_module_list)
async def add(ctx: discord.ApplicationContext, module: str):
await slash_parser(ctx, f"enable {module}")


@m.command(name="disable", description="Disable module(s).")
@discord.option(name="module", description="The modules you want to disable.", autocomplete=auto_get_module_list)
async def add(ctx: discord.ApplicationContext, module: str):
await slash_parser(ctx, f"disable {module}")


@m.command(name="list", description="View all available modules.")
@discord.option(name="legacy", choices=['false', 'true'], description="Whether to use legacy mode.")
async def lst(ctx: discord.ApplicationContext, legacy: str):
legacy = "legacy" if legacy == "true" else ""
await slash_parser(ctx, f"list {legacy}")


p = client.create_group("prefix", "Set custom command prefix.")


@p.command(description="Add custom command prefix.")
@p.command(name="add", 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.")
@p.command(name="remove", 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):
@p.command(name="list", description="View custom command prefix.")
async def lst(ctx: discord.ApplicationContext):
await slash_parser(ctx, "list")


@p.command(description="Reset custom command prefix.")
@p.command(name="reset", 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.")


@setup.command(description="Set up whether to display input prompts.")
@setup.command(name="typing", description="Set up whether to display input prompts.")
async def typing(ctx: discord.ApplicationContext):
await slash_parser(ctx, "typing")


@setup.command(description="Set the time offset.")
@setup.command(name="timeoffset", 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}")
10 changes: 5 additions & 5 deletions bots/discord/slash/cytoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@
cytoid = client.create_group("cytoid", "Query about Cytoid.")


@cytoid.command(description="Query the Best 30 list.")
@cytoid.command(name="b30", description="Query the Best 30 list.")
async def b30(ctx: discord.ApplicationContext):
await slash_parser(ctx, "b30")


@cytoid.command(description="Query the Recent 30 list.")
@cytoid.command(name="r30", description="Query the Recent 30 list.")
async def r30(ctx: discord.ApplicationContext):
await slash_parser(ctx, "r30")


@cytoid.command(description="Query user profile.")
@cytoid.command(name="profile", description="Query user profile.")
async def profile(ctx: discord.ApplicationContext):
await slash_parser(ctx, "profile")


@cytoid.command(description="Bind user.")
@cytoid.command(name="bind", description="Bind user.")
@discord.option(name="username", description="Your Cytoid username.")
async def bind(ctx: discord.ApplicationContext, username: str):
await slash_parser(ctx, f"bind {username}")


@cytoid.command(description="Unbind user.")
@cytoid.command(name="unbind", description="Unbind user.")
async def unbind(ctx: discord.ApplicationContext):
await slash_parser(ctx, "unbind")
4 changes: 2 additions & 2 deletions bots/discord/slash/dice.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ async def auto_complete(ctx: discord.AutocompleteContext):
dice = client.create_group("dice", "Random dice.")


@dice.command(description="Roll the specified dice.")
@dice.command(name="roll", description="Roll the specified dice.")
@discord.option(name="dices", autocomplete=auto_complete, description="Dice expression.")
@discord.option(name="dc", default="", description="Difficulty class.")
async def roll(ctx: discord.ApplicationContext, dices: str, dc: str):
await slash_parser(ctx, f'{dices} {dc}')


@dice.command(description="Modify the checking rule of dc.")
@dice.command(name="rule", description="Modify the checking rule of dc.")
async def rule(ctx: discord.ApplicationContext):
await slash_parser(ctx, 'rule')
4 changes: 2 additions & 2 deletions bots/discord/slash/exchange_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from bots.discord.client import client
from bots.discord.slash_parser import slash_parser

@client.slash_command(description="Convert currency prices according to the exchange rate of the day.")
@client.slash_command(name="exchange_rate", description="Convert currency prices according to the exchange rate of the day.")
@discord.option(name="amount", description="The amount of base currency.")
@discord.option(name="base", description="The base currency unit.")
@discord.option(name="target", description="The target currency unit.")
async def exchange_rate(ctx: discord.ApplicationContext, amount: float, base: str, target: str):
async def excr(ctx: discord.ApplicationContext, amount: float, base: str, target: str):
await slash_parser(ctx, f"{amount}{base} {target}")
8 changes: 4 additions & 4 deletions bots/discord/slash/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@
github = client.create_group("github", "Github query tool.")


@github.command(description="Trying to automatically identifying and distinguishing repo/user.")
@github.command(name="get", description="Trying to automatically identifying and distinguishing repo/user.")
@discord.option(name="name", description="GitHub user or repository name.")
async def get(ctx: discord.ApplicationContext, name: str):
await slash_parser(ctx, name)


@github.command(description="Get GitHub repository information.")
@github.command(name="repo", description="Get GitHub repository information.")
@discord.option(name="name", description="GitHub repository name.")
async def repo(ctx: discord.ApplicationContext, name: str):
await slash_parser(ctx, f'repo {name}')


@github.command(description="Get GitHub user or organization information.")
@github.command(name="user", description="Get GitHub user or organization information.")
@discord.option(name="name", description="GitHub user name.")
async def user(ctx: discord.ApplicationContext, name: str):
await slash_parser(ctx, f'user {name}')


@github.command(description="Search repositories on GitHub.")
@github.command(name="search", description="Search repositories on GitHub.")
@discord.option(name="query", description="Search keywords.")
async def search(ctx: discord.ApplicationContext, query: str):
await slash_parser(ctx, f'search {keyword}')
28 changes: 0 additions & 28 deletions bots/discord/slash/idlist.py

This file was deleted.

Loading

0 comments on commit d8e6733

Please sign in to comment.