From c21e29f3d790658581d5c1ffbc1e0267a6d7b755 Mon Sep 17 00:00:00 2001 From: thororen <78185467+thororen1234@users.noreply.github.com> Date: Sat, 4 May 2024 01:10:12 -0400 Subject: [PATCH] Haha Funny Moment --- scripts/generatePluginList.ts | 35 ++++++++++++++++++- src/plugins/_core/supportHelper.tsx | 4 +-- src/plugins/equicordToolbox/index.tsx | 3 +- .../readAllNotificationsButton/index.tsx | 4 +-- 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/scripts/generatePluginList.ts b/scripts/generatePluginList.ts index e8aa33a4..f4dfa385 100644 --- a/scripts/generatePluginList.ts +++ b/scripts/generatePluginList.ts @@ -44,6 +44,7 @@ interface PluginData { } const devs = {} as Record; +const equicordDevs = {} as Record; function getName(node: NamedDeclaration) { return node.name && isIdentifier(node.name) ? node.name.text : undefined; @@ -90,6 +91,37 @@ function parseDevs() { throw new Error("Could not find Devs constant"); } +function parseEquicordDevs() { + const file = createSourceFile("constants.ts", readFileSync("src/utils/constants.ts", "utf8"), ScriptTarget.Latest); + + for (const child of file.getChildAt(0).getChildren()) { + if (!isVariableStatement(child)) continue; + + const devsDeclaration = child.declarationList.declarations.find(d => hasName(d, "EquicordDevs")); + if (!devsDeclaration?.initializer || !isCallExpression(devsDeclaration.initializer)) continue; + + const value = devsDeclaration.initializer.arguments[0]; + + if (!isSatisfiesExpression(value) || !isObjectLiteralExpression(value.expression)) throw new Error("Failed to parse EquicordDevs: not an object literal"); + + for (const prop of value.expression.properties) { + const name = (prop.name as Identifier).text; + const value = isPropertyAssignment(prop) ? prop.initializer : prop; + + if (!isObjectLiteralExpression(value)) throw new Error(`Failed to parse EquicordDevs: ${name} is not an object literal`); + + equicordDevs[name] = { + name: (getObjectProp(value, "name") as StringLiteral).text, + id: (getObjectProp(value, "id") as BigIntLiteral).text.slice(0, -1) + }; + } + + return; + } + + throw new Error("Could not find EquicordDevs constant"); +} + async function parseFile(fileName: string) { const file = createSourceFile(fileName, await readFile(fileName, "utf8"), ScriptTarget.Latest); @@ -134,7 +166,7 @@ async function parseFile(fileName: string) { if (!isArrayLiteralExpression(value)) throw fail("authors is not an array literal"); data.authors = value.elements.map(e => { if (!isPropertyAccessExpression(e)) throw fail("authors array contains non-property access expressions"); - const d = devs[getName(e)!]; + const d = devs[getName(e)!] || equicordDevs[getName(e)!]; if (!d) throw fail(`couldn't look up author ${getName(e)}`); return d; }); @@ -205,6 +237,7 @@ function isPluginFile({ name }: { name: string; }) { (async () => { parseDevs(); + parseEquicordDevs(); const plugins = [] as PluginData[]; const readmes = {} as Record; diff --git a/src/plugins/_core/supportHelper.tsx b/src/plugins/_core/supportHelper.tsx index 791fd399..8cb7d18a 100644 --- a/src/plugins/_core/supportHelper.tsx +++ b/src/plugins/_core/supportHelper.tsx @@ -17,7 +17,7 @@ */ import { DataStore } from "@api/index"; -import { Devs, SUPPORT_CHANNEL_ID, SUPPORT_CHANNEL_IDS, VC_SUPPORT_CHANNEL_ID } from "@utils/constants"; +import { Devs, EquicordDevs, SUPPORT_CHANNEL_ID, SUPPORT_CHANNEL_IDS, VC_SUPPORT_CHANNEL_ID } from "@utils/constants"; import { isEquicordPluginDev, isPluginDev } from "@utils/misc"; import { makeCodeblock } from "@utils/text"; import definePlugin from "@utils/types"; @@ -41,7 +41,7 @@ export default definePlugin({ name: "SupportHelper", required: true, description: "Helps us provide support to you", - authors: [Devs.Ven], + authors: [Devs.Ven, EquicordDevs.thororen], dependencies: ["CommandsAPI"], commands: [{ diff --git a/src/plugins/equicordToolbox/index.tsx b/src/plugins/equicordToolbox/index.tsx index 66ac10a4..4713bc53 100644 --- a/src/plugins/equicordToolbox/index.tsx +++ b/src/plugins/equicordToolbox/index.tsx @@ -19,7 +19,7 @@ import "./index.css"; import { openNotificationLogModal } from "@api/Notifications/notificationLog"; -import { Settings, useSettings } from "@api/Settings"; +import { migratePluginSettings, Settings, useSettings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; @@ -130,6 +130,7 @@ function ToolboxFragmentWrapper({ children }: { children: ReactNode[]; }) { return <>{children}; } +migratePluginSettings("EquicordToolbox", "VencordToolbox"); export default definePlugin({ name: "EquicordToolbox", description: "Adds a button next to the inbox button in the channel header that houses Equicord quick actions", diff --git a/src/plugins/readAllNotificationsButton/index.tsx b/src/plugins/readAllNotificationsButton/index.tsx index ae66e11a..bb975afd 100644 --- a/src/plugins/readAllNotificationsButton/index.tsx +++ b/src/plugins/readAllNotificationsButton/index.tsx @@ -19,7 +19,7 @@ import "./style.css"; import { addServerListElement, removeServerListElement, ServerListRenderPosition } from "@api/ServerList"; -import { Devs } from "@utils/constants"; +import { Devs, EquicordDevs } from "@utils/constants"; import definePlugin from "@utils/types"; import { Button, FluxDispatcher, GuildChannelStore, GuildStore, React, ReadStateStore } from "@webpack/common"; @@ -61,7 +61,7 @@ const ReadAllButton = () => ( export default definePlugin({ name: "ReadAllNotificationsButton", description: "Read all server notifications with a single button click!", - authors: [Devs.kemo], + authors: [Devs.kemo, EquicordDevs.KrystalSkull], dependencies: ["ServerListAPI"], renderReadAllButton: () => ,