3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

refactor: consolidate pluginInfo internal/legacy fields

This commit is contained in:
Dragory 2024-05-19 11:15:03 +00:00
parent 8a4f7fe0e8
commit dfdc6566cf
No known key found for this signature in database
41 changed files with 46 additions and 51 deletions

View file

@ -98,13 +98,13 @@ function formatZodConfigSchema(schema: z.ZodTypeAny) {
} }
export function initDocs(router: express.Router) { export function initDocs(router: express.Router) {
const docsPluginNames = Object.keys(guildPluginInfo).filter((k) => guildPluginInfo[k].showInDocs); const docsPluginNames = Object.keys(guildPluginInfo).filter((k) => guildPluginInfo[k].type === "stable" || guildPluginInfo[k].type === "legacy");
router.get("/docs/plugins", (req: express.Request, res: express.Response) => { router.get("/docs/plugins", (req: express.Request, res: express.Response) => {
res.json( res.json(
docsPluginNames.map((pluginName) => { docsPluginNames.map((pluginName) => {
const info = guildPluginInfo[pluginName]; const info = guildPluginInfo[pluginName]!;
const thinInfo = info ? { prettyName: info.prettyName, legacy: info.legacy ?? false } : {}; const thinInfo = { prettyName: info.prettyName, type: info.type };
return { return {
name: pluginName, name: pluginName,
info: thinInfo, info: thinInfo,

View file

@ -2,7 +2,7 @@ import { ZeppelinPluginInfo } from "../../types.js";
import { zAutoDeleteConfig } from "./types.js"; import { zAutoDeleteConfig } from "./types.js";
export const autoDeletePluginInfo: ZeppelinPluginInfo = { export const autoDeletePluginInfo: ZeppelinPluginInfo = {
showInDocs: true, type: "stable",
prettyName: "Auto-delete", prettyName: "Auto-delete",
description: "Allows Zeppelin to auto-delete messages from a channel after a delay", description: "Allows Zeppelin to auto-delete messages from a channel after a delay",
configurationGuide: "Maximum deletion delay is currently 5 minutes", configurationGuide: "Maximum deletion delay is currently 5 minutes",

View file

@ -3,7 +3,7 @@ import { trimPluginDescription } from "../../utils.js";
import { zAutoReactionsConfig } from "./types.js"; import { zAutoReactionsConfig } from "./types.js";
export const autoReactionsInfo: ZeppelinPluginInfo = { export const autoReactionsInfo: ZeppelinPluginInfo = {
showInDocs: true, type: "stable",
prettyName: "Auto-reactions", prettyName: "Auto-reactions",
description: trimPluginDescription(` description: trimPluginDescription(`
Allows setting up automatic reactions to all new messages on a channel Allows setting up automatic reactions to all new messages on a channel

View file

@ -3,7 +3,7 @@ import { trimPluginDescription } from "../../utils.js";
import { zAutomodConfig } from "./types.js"; import { zAutomodConfig } from "./types.js";
export const automodPluginInfo: ZeppelinPluginInfo = { export const automodPluginInfo: ZeppelinPluginInfo = {
showInDocs: true, type: "stable",
prettyName: "Automod", prettyName: "Automod",
configSchema: zAutomodConfig, configSchema: zAutomodConfig,
description: trimPluginDescription(` description: trimPluginDescription(`

View file

@ -3,7 +3,7 @@ import { trimPluginDescription } from "../../utils.js";
import { zCasesConfig } from "./types.js"; import { zCasesConfig } from "./types.js";
export const casesPluginInfo: ZeppelinPluginInfo = { export const casesPluginInfo: ZeppelinPluginInfo = {
showInDocs: true, type: "stable",
prettyName: "Cases", prettyName: "Cases",
configSchema: zCasesConfig, configSchema: zCasesConfig,
description: trimPluginDescription(` description: trimPluginDescription(`

View file

@ -3,8 +3,7 @@ import { trimPluginDescription } from "../../utils.js";
import { zCensorConfig } from "./types.js"; import { zCensorConfig } from "./types.js";
export const censorPluginInfo: ZeppelinPluginInfo = { export const censorPluginInfo: ZeppelinPluginInfo = {
showInDocs: true, type: "legacy",
legacy: true,
prettyName: "Censor", prettyName: "Censor",
configSchema: zCensorConfig, configSchema: zCensorConfig,
description: trimPluginDescription(` description: trimPluginDescription(`

View file

@ -3,7 +3,7 @@ import { trimPluginDescription } from "../../utils.js";
import { zCompanionChannelsConfig } from "./types.js"; import { zCompanionChannelsConfig } from "./types.js";
export const companionChannelsPluginInfo: ZeppelinPluginInfo = { export const companionChannelsPluginInfo: ZeppelinPluginInfo = {
showInDocs: true, type: "stable",
prettyName: "Companion channels", prettyName: "Companion channels",
configSchema: zCompanionChannelsConfig, configSchema: zCompanionChannelsConfig,
description: trimPluginDescription(` description: trimPluginDescription(`

View file

@ -2,7 +2,7 @@ import { ZeppelinPluginInfo } from "../../types.js";
import { zContextMenusConfig } from "./types.js"; import { zContextMenusConfig } from "./types.js";
export const contextMenuPluginInfo: ZeppelinPluginInfo = { export const contextMenuPluginInfo: ZeppelinPluginInfo = {
showInDocs: false, type: "stable",
prettyName: "Context menu", prettyName: "Context menu",
configSchema: zContextMenusConfig, configSchema: zContextMenusConfig,
}; };

View file

@ -3,7 +3,7 @@ import { zCountersConfig } from "./types.js";
export const countersPluginInfo: ZeppelinPluginInfo = { export const countersPluginInfo: ZeppelinPluginInfo = {
prettyName: "Counters", prettyName: "Counters",
showInDocs: true, type: "stable",
description: description:
"Keep track of per-user, per-channel, or global numbers and trigger specific actions based on this number", "Keep track of per-user, per-channel, or global numbers and trigger specific actions based on this number",
configurationGuide: "See <a href='/docs/setup-guides/counters'>Counters setup guide</a>", configurationGuide: "See <a href='/docs/setup-guides/counters'>Counters setup guide</a>",

View file

@ -3,6 +3,6 @@ import { zCustomEventsConfig } from "./types.js";
export const customEventsPluginInfo: ZeppelinPluginInfo = { export const customEventsPluginInfo: ZeppelinPluginInfo = {
prettyName: "Custom events", prettyName: "Custom events",
showInDocs: false, type: "internal",
configSchema: zCustomEventsConfig, configSchema: zCustomEventsConfig,
}; };

View file

@ -3,6 +3,6 @@ import { zGuildConfigReloaderPlugin } from "./types.js";
export const guildConfigReloaderPluginInfo: ZeppelinPluginInfo = { export const guildConfigReloaderPluginInfo: ZeppelinPluginInfo = {
prettyName: "Guild config reloader", prettyName: "Guild config reloader",
showInDocs: false, type: "internal",
configSchema: zGuildConfigReloaderPlugin, configSchema: zGuildConfigReloaderPlugin,
}; };

View file

@ -3,6 +3,6 @@ import { zGuildInfoSaverConfig } from "./types.js";
export const guildInfoSaverPluginInfo: ZeppelinPluginInfo = { export const guildInfoSaverPluginInfo: ZeppelinPluginInfo = {
prettyName: "Guild info saver", prettyName: "Guild info saver",
showInDocs: false, type: "internal",
configSchema: zGuildInfoSaverConfig, configSchema: zGuildInfoSaverConfig,
}; };

View file

@ -3,6 +3,6 @@ import { zGuildMemberCacheConfig } from "./types.js";
export const guildMemberCachePluginInfo: ZeppelinPluginInfo = { export const guildMemberCachePluginInfo: ZeppelinPluginInfo = {
prettyName: "Guild member cache", prettyName: "Guild member cache",
showInDocs: false, type: "internal",
configSchema: zGuildMemberCacheConfig, configSchema: zGuildMemberCacheConfig,
}; };

View file

@ -3,6 +3,6 @@ import { zInternalPosterConfig } from "./types.js";
export const internalPosterPluginInfo: ZeppelinPluginInfo = { export const internalPosterPluginInfo: ZeppelinPluginInfo = {
prettyName: "Internal poster", prettyName: "Internal poster",
showInDocs: false, type: "internal",
configSchema: zInternalPosterConfig, configSchema: zInternalPosterConfig,
}; };

View file

@ -4,11 +4,11 @@ import { zLocateUserConfig } from "./types.js";
export const locateUserPluginInfo: ZeppelinPluginInfo = { export const locateUserPluginInfo: ZeppelinPluginInfo = {
prettyName: "Locate user", prettyName: "Locate user",
type: "stable",
description: trimPluginDescription(` description: trimPluginDescription(`
This plugin allows users with access to the commands the following: This plugin allows users with access to the commands the following:
* Instantly receive an invite to the voice channel of a user * Instantly receive an invite to the voice channel of a user
* Be notified as soon as a user switches or joins a voice channel * Be notified as soon as a user switches or joins a voice channel
`), `),
configSchema: zLocateUserConfig, configSchema: zLocateUserConfig,
showInDocs: true,
}; };

View file

@ -4,5 +4,5 @@ import { zLogsConfig } from "./types.js";
export const logsPluginInfo: ZeppelinPluginInfo = { export const logsPluginInfo: ZeppelinPluginInfo = {
prettyName: "Logs", prettyName: "Logs",
configSchema: zLogsConfig, configSchema: zLogsConfig,
showInDocs: true, type: "stable",
}; };

View file

@ -3,6 +3,6 @@ import { zMessageSaverConfig } from "./types.js";
export const messageSaverPluginInfo: ZeppelinPluginInfo = { export const messageSaverPluginInfo: ZeppelinPluginInfo = {
prettyName: "Message saver", prettyName: "Message saver",
showInDocs: false, type: "internal",
configSchema: zMessageSaverConfig, configSchema: zMessageSaverConfig,
}; };

View file

@ -4,7 +4,7 @@ import { zModActionsConfig } from "./types.js";
export const modActionsPluginInfo: ZeppelinPluginInfo = { export const modActionsPluginInfo: ZeppelinPluginInfo = {
prettyName: "Mod actions", prettyName: "Mod actions",
showInDocs: true, type: "stable",
description: trimPluginDescription(` description: trimPluginDescription(`
This plugin contains the 'typical' mod actions such as warning, muting, kicking, banning, etc. This plugin contains the 'typical' mod actions such as warning, muting, kicking, banning, etc.
`), `),

View file

@ -3,6 +3,6 @@ import { zMutesConfig } from "./types.js";
export const mutesPluginInfo: ZeppelinPluginInfo = { export const mutesPluginInfo: ZeppelinPluginInfo = {
prettyName: "Mutes", prettyName: "Mutes",
showInDocs: true, type: "stable",
configSchema: zMutesConfig, configSchema: zMutesConfig,
}; };

View file

@ -3,6 +3,6 @@ import { zNameHistoryConfig } from "./types.js";
export const nameHistoryPluginInfo: ZeppelinPluginInfo = { export const nameHistoryPluginInfo: ZeppelinPluginInfo = {
prettyName: "Name history", prettyName: "Name history",
showInDocs: false, type: "internal",
configSchema: zNameHistoryConfig, configSchema: zNameHistoryConfig,
}; };

View file

@ -9,5 +9,5 @@ export const persistPluginInfo: ZeppelinPluginInfo = {
Mute roles are re-applied automatically, this plugin is not required for that. Mute roles are re-applied automatically, this plugin is not required for that.
`), `),
configSchema: zPersistConfig, configSchema: zPersistConfig,
showInDocs: true, type: "stable",
}; };

View file

@ -4,6 +4,7 @@ import { zPhishermanConfig } from "./types.js";
export const phishermanPluginInfo: ZeppelinPluginInfo = { export const phishermanPluginInfo: ZeppelinPluginInfo = {
prettyName: "Phisherman", prettyName: "Phisherman",
type: "stable",
description: trimPluginDescription(` description: trimPluginDescription(`
Match scam/phishing links using the Phisherman API. See https://phisherman.gg/ for more details! Match scam/phishing links using the Phisherman API. See https://phisherman.gg/ for more details!
`), `),
@ -40,5 +41,4 @@ export const phishermanPluginInfo: ZeppelinPluginInfo = {
~~~ ~~~
`), `),
configSchema: zPhishermanConfig, configSchema: zPhishermanConfig,
showInDocs: true,
}; };

View file

@ -4,5 +4,5 @@ import { zPingableRolesConfig } from "./types.js";
export const pingableRolesPluginInfo: ZeppelinPluginInfo = { export const pingableRolesPluginInfo: ZeppelinPluginInfo = {
prettyName: "Pingable roles", prettyName: "Pingable roles",
configSchema: zPingableRolesConfig, configSchema: zPingableRolesConfig,
showInDocs: true, type: "stable",
}; };

View file

@ -4,5 +4,5 @@ import { zPostConfig } from "./types.js";
export const postPluginInfo: ZeppelinPluginInfo = { export const postPluginInfo: ZeppelinPluginInfo = {
prettyName: "Post", prettyName: "Post",
configSchema: zPostConfig, configSchema: zPostConfig,
showInDocs: true, type: "stable",
}; };

View file

@ -4,7 +4,6 @@ import { zReactionRolesConfig } from "./types.js";
export const reactionRolesPluginInfo: ZeppelinPluginInfo = { export const reactionRolesPluginInfo: ZeppelinPluginInfo = {
prettyName: "Reaction roles", prettyName: "Reaction roles",
description: "Consider using the [Role buttons](https://zeppelin.gg/docs/plugins/role_buttons) plugin instead.", description: "Consider using the [Role buttons](https://zeppelin.gg/docs/plugins/role_buttons) plugin instead.",
legacy: true, type: "legacy",
configSchema: zReactionRolesConfig, configSchema: zReactionRolesConfig,
showInDocs: true,
}; };

View file

@ -4,5 +4,5 @@ import { zRemindersConfig } from "./types.js";
export const remindersPluginInfo: ZeppelinPluginInfo = { export const remindersPluginInfo: ZeppelinPluginInfo = {
prettyName: "Reminders", prettyName: "Reminders",
configSchema: zRemindersConfig, configSchema: zRemindersConfig,
showInDocs: true, type: "stable",
}; };

View file

@ -3,7 +3,7 @@ import { trimPluginDescription } from "../../utils.js";
import { zRoleButtonsConfig } from "./types.js"; import { zRoleButtonsConfig } from "./types.js";
export const roleButtonsPluginInfo: ZeppelinPluginInfo = { export const roleButtonsPluginInfo: ZeppelinPluginInfo = {
showInDocs: true, type: "stable",
prettyName: "Role buttons", prettyName: "Role buttons",
description: trimPluginDescription(` description: trimPluginDescription(`
Allow users to pick roles by clicking on buttons Allow users to pick roles by clicking on buttons

View file

@ -3,6 +3,6 @@ import { zRoleManagerConfig } from "./types.js";
export const roleManagerPluginInfo: ZeppelinPluginInfo = { export const roleManagerPluginInfo: ZeppelinPluginInfo = {
prettyName: "Role manager", prettyName: "Role manager",
showInDocs: false, type: "internal",
configSchema: zRoleManagerConfig, configSchema: zRoleManagerConfig,
}; };

View file

@ -3,7 +3,7 @@ import { trimPluginDescription } from "../../utils.js";
import { zRolesConfig } from "./types.js"; import { zRolesConfig } from "./types.js";
export const rolesPluginInfo: ZeppelinPluginInfo = { export const rolesPluginInfo: ZeppelinPluginInfo = {
showInDocs: true, type: "stable",
prettyName: "Roles", prettyName: "Roles",
description: trimPluginDescription(` description: trimPluginDescription(`
Enables authorised users to add and remove whitelisted roles with a command. Enables authorised users to add and remove whitelisted roles with a command.

View file

@ -3,7 +3,7 @@ import { trimPluginDescription } from "../../utils.js";
import { zSelfGrantableRolesConfig } from "./types.js"; import { zSelfGrantableRolesConfig } from "./types.js";
export const selfGrantableRolesPluginInfo: ZeppelinPluginInfo = { export const selfGrantableRolesPluginInfo: ZeppelinPluginInfo = {
showInDocs: true, type: "stable",
prettyName: "Self-grantable roles", prettyName: "Self-grantable roles",
description: trimPluginDescription(` description: trimPluginDescription(`
Allows users to grant themselves roles via a command Allows users to grant themselves roles via a command

View file

@ -2,7 +2,7 @@ import { ZeppelinPluginInfo } from "../../types.js";
import { zSlowmodeConfig } from "./types.js"; import { zSlowmodeConfig } from "./types.js";
export const slowmodePluginInfo: ZeppelinPluginInfo = { export const slowmodePluginInfo: ZeppelinPluginInfo = {
showInDocs: true, type: "stable",
prettyName: "Slowmode", prettyName: "Slowmode",
configSchema: zSlowmodeConfig, configSchema: zSlowmodeConfig,
}; };

View file

@ -3,12 +3,11 @@ import { trimPluginDescription } from "../../utils.js";
import { zSpamConfig } from "./types.js"; import { zSpamConfig } from "./types.js";
export const spamPluginInfo: ZeppelinPluginInfo = { export const spamPluginInfo: ZeppelinPluginInfo = {
showInDocs: true, type: "legacy",
prettyName: "Spam protection", prettyName: "Spam protection",
description: trimPluginDescription(` description: trimPluginDescription(`
Basic spam detection and auto-muting. Basic spam detection and auto-muting.
For more advanced spam filtering, check out the Automod plugin! For more advanced spam filtering, check out the Automod plugin!
`), `),
legacy: true,
configSchema: zSpamConfig, configSchema: zSpamConfig,
}; };

View file

@ -3,7 +3,7 @@ import { trimPluginDescription } from "../../utils.js";
import { zStarboardConfig } from "./types.js"; import { zStarboardConfig } from "./types.js";
export const starboardPluginInfo: ZeppelinPluginInfo = { export const starboardPluginInfo: ZeppelinPluginInfo = {
showInDocs: true, type: "stable",
prettyName: "Starboard", prettyName: "Starboard",
description: trimPluginDescription(` description: trimPluginDescription(`
This plugin allows you to set up starboards on your server. Starboards are like user voted pins where messages with enough reactions get immortalized on a "starboard" channel. This plugin allows you to set up starboards on your server. Starboards are like user voted pins where messages with enough reactions get immortalized on a "starboard" channel.

View file

@ -4,7 +4,7 @@ import { TemplateFunctions } from "./templateFunctions.js";
import { TemplateFunction, zTagsConfig } from "./types.js"; import { TemplateFunction, zTagsConfig } from "./types.js";
export const tagsPluginInfo: ZeppelinPluginInfo = { export const tagsPluginInfo: ZeppelinPluginInfo = {
showInDocs: true, type: "stable",
prettyName: "Tags", prettyName: "Tags",
description: "Tags are a way to store and reuse information.", description: "Tags are a way to store and reuse information.",
configurationGuide: trimPluginDescription(` configurationGuide: trimPluginDescription(`

View file

@ -3,7 +3,7 @@ import { trimPluginDescription } from "../../utils.js";
import { zTimeAndDateConfig } from "./types.js"; import { zTimeAndDateConfig } from "./types.js";
export const timeAndDatePluginInfo: ZeppelinPluginInfo = { export const timeAndDatePluginInfo: ZeppelinPluginInfo = {
showInDocs: true, type: "stable",
prettyName: "Time and date", prettyName: "Time and date",
description: trimPluginDescription(` description: trimPluginDescription(`
Allows controlling the displayed time/date formats and timezones Allows controlling the displayed time/date formats and timezones

View file

@ -2,7 +2,7 @@ import { ZeppelinPluginInfo } from "../../types.js";
import { zUsernameSaverConfig } from "./types.js"; import { zUsernameSaverConfig } from "./types.js";
export const usernameSaverPluginInfo: ZeppelinPluginInfo = { export const usernameSaverPluginInfo: ZeppelinPluginInfo = {
showInDocs: false, type: "internal",
prettyName: "Username saver", prettyName: "Username saver",
configSchema: zUsernameSaverConfig, configSchema: zUsernameSaverConfig,
}; };

View file

@ -2,7 +2,7 @@ import { ZeppelinPluginInfo } from "../../types.js";
import { zUtilityConfig } from "./types.js"; import { zUtilityConfig } from "./types.js";
export const utilityPluginInfo: ZeppelinPluginInfo = { export const utilityPluginInfo: ZeppelinPluginInfo = {
showInDocs: true, type: "stable",
prettyName: "Utility", prettyName: "Utility",
configSchema: zUtilityConfig, configSchema: zUtilityConfig,
}; };

View file

@ -2,7 +2,7 @@ import { ZeppelinPluginInfo } from "../../types.js";
import { zWelcomeMessageConfig } from "./types.js"; import { zWelcomeMessageConfig } from "./types.js";
export const welcomeMessagePluginInfo: ZeppelinPluginInfo = { export const welcomeMessagePluginInfo: ZeppelinPluginInfo = {
showInDocs: true, type: "stable",
prettyName: "Welcome message", prettyName: "Welcome message",
configSchema: zWelcomeMessageConfig, configSchema: zWelcomeMessageConfig,
}; };

View file

@ -33,14 +33,15 @@ export type TZeppelinKnub = Knub;
*/ */
export type TMarkdown = string; export type TMarkdown = string;
export type ZeppelinPluginType = "stable" | "legacy" | "internal";
export interface ZeppelinPluginInfo { export interface ZeppelinPluginInfo {
showInDocs: boolean; type: ZeppelinPluginType;
prettyName: string; prettyName: string;
configSchema: ZodTypeAny; configSchema: ZodTypeAny;
description?: TMarkdown; description?: TMarkdown;
usageGuide?: TMarkdown; usageGuide?: TMarkdown;
configurationGuide?: TMarkdown; configurationGuide?: TMarkdown;
legacy?: boolean;
} }
export interface CommandInfo { export interface CommandInfo {

View file

@ -156,14 +156,14 @@
...menu, ...menu,
{ {
label: 'Plugins', label: 'Plugins',
items: this.plugins.filter(plugin => !plugin.info.legacy).map(plugin => ({ items: this.plugins.filter(plugin => plugin.info.type === "stable").map(plugin => ({
label: plugin.info.prettyName || plugin.name, label: plugin.info.prettyName || plugin.name,
to: `/docs/plugins/${plugin.name}`, to: `/docs/plugins/${plugin.name}`,
})), })),
}, },
{ {
label: "Legacy Plugins", label: "Legacy Plugins",
items: this.plugins.filter(plugin => plugin.info.legacy).map(plugin => ({ items: this.plugins.filter(plugin => plugin.info.type === "legacy").map(plugin => ({
label: plugin.info.prettyName || plugin.name, label: plugin.info.prettyName || plugin.name,
to: `/docs/plugins/${plugin.name}`, to: `/docs/plugins/${plugin.name}`,
})), })),

View file

@ -8,16 +8,13 @@
<!-- Description --> <!-- Description -->
<MarkdownBlock :content="data.info.description" class="content"></MarkdownBlock> <MarkdownBlock :content="data.info.description" class="content"></MarkdownBlock>
<div v-if="data.info.legacy"> <div v-if="data.info.type === 'legacy'">
<div class="px-3 py-2 mb-4 rounded bg-gray-800 shadow-md inline-block flex"> <div class="px-3 py-2 mb-4 rounded bg-gray-800 shadow-md inline-block flex">
<div class="flex-none mr-2"> <div class="flex-none mr-2">
<alert class="inline-icon mr-1 text-yellow-300" /> <alert class="inline-icon mr-1 text-yellow-300" />
</div> </div>
<div class="flex-auto"> <div class="flex-auto">
<strong>Note!</strong> This is a legacy plugin which is no longer actively maintained and may be removed in a future update. <strong>Note!</strong> This is a legacy plugin which is no longer actively maintained and may be removed in a future update.
<div v-if="typeof data.info.legacy === 'string'" class="mt-4">
<MarkdownBlock v-if="typeof data.info.legacy === 'string'" :content="data.info.legacy"></MarkdownBlock>
</div>
</div> </div>
</div> </div>
</div> </div>