2024-03-06 01:57:59 +08:00
|
|
|
import { Strings } from "@core/i18n";
|
|
|
|
|
import { ApplicationCommand, ApplicationCommandOptionType } from "@lib/api/commands/types";
|
2024-06-25 02:28:04 +08:00
|
|
|
import { BunnyPlugin, sourceStore as pluginStorage } from "@lib/managers/plugins";
|
2024-03-06 01:57:59 +08:00
|
|
|
import { messageUtil } from "@metro/common";
|
2024-02-27 23:35:55 +08:00
|
|
|
|
|
|
|
|
export default () => <ApplicationCommand>{
|
|
|
|
|
name: "plugins",
|
2024-03-05 23:41:45 +08:00
|
|
|
description: Strings.COMMAND_PLUGINS_DESC,
|
2024-02-27 23:35:55 +08:00
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
name: "ephemeral",
|
|
|
|
|
displayName: "ephemeral",
|
|
|
|
|
type: ApplicationCommandOptionType.BOOLEAN,
|
|
|
|
|
description: Strings.COMMAND_DEBUG_OPT_EPHEMERALLY,
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
execute([ephemeral], ctx) {
|
2024-06-18 02:19:31 +08:00
|
|
|
const plugins = Object.values(pluginStorage).filter(Boolean) as unknown as BunnyPlugin[];
|
|
|
|
|
plugins.sort((a, b) => a.manifest.name.localeCompare(b.manifest.name));
|
2024-02-27 23:35:55 +08:00
|
|
|
|
|
|
|
|
const enabled = plugins.filter(p => p.enabled).map(p => p.manifest.name);
|
|
|
|
|
const disabled = plugins.filter(p => !p.enabled).map(p => p.manifest.name);
|
|
|
|
|
|
|
|
|
|
const content = [
|
|
|
|
|
`**Installed Plugins (${plugins.length}):**`,
|
|
|
|
|
...(enabled.length > 0 ? [
|
|
|
|
|
`Enabled (${enabled.length}):`,
|
|
|
|
|
"> " + enabled.join(", "),
|
|
|
|
|
] : []),
|
|
|
|
|
...(disabled.length > 0 ? [
|
|
|
|
|
`Disabled (${disabled.length}):`,
|
|
|
|
|
"> " + disabled.join(", "),
|
|
|
|
|
] : []),
|
|
|
|
|
].join("\n");
|
|
|
|
|
|
|
|
|
|
if (ephemeral?.value) {
|
|
|
|
|
messageUtil.sendBotMessage(ctx.channel.id, content);
|
|
|
|
|
} else {
|
|
|
|
|
messageUtil.sendMessage(ctx.channel.id, { content });
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-06 01:57:59 +08:00
|
|
|
};
|