diff options
author | Vendicated <vendicated@riseup.net> | 2023-02-28 02:40:45 +0100 |
---|---|---|
committer | Vendicated <vendicated@riseup.net> | 2023-02-28 02:40:45 +0100 |
commit | c09d1558f7a2f707b365e2bd55ab70d79b093f18 (patch) | |
tree | 172b3a1f72a5001e379161d4ea24253b794f7d39 /src/plugins | |
parent | eb190b660e2e2e932dcb62c567b9c611330964eb (diff) | |
download | Vencord-c09d1558f7a2f707b365e2bd55ab70d79b093f18.tar.gz Vencord-c09d1558f7a2f707b365e2bd55ab70d79b093f18.tar.bz2 Vencord-c09d1558f7a2f707b365e2bd55ab70d79b093f18.zip |
Add SupportHelper plugin
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/consoleShortcuts.ts | 2 | ||||
-rw-r--r-- | src/plugins/supportHelper.tsx | 89 |
2 files changed, 90 insertions, 1 deletions
diff --git a/src/plugins/consoleShortcuts.ts b/src/plugins/consoleShortcuts.ts index bfcd1a1..83b5291 100644 --- a/src/plugins/consoleShortcuts.ts +++ b/src/plugins/consoleShortcuts.ts @@ -59,7 +59,7 @@ export default definePlugin({ } return { - wp: Webpack, + wp: Vencord.Webpack, wpc: Webpack.wreq.c, wreq: Webpack.wreq, wpsearch: search, diff --git a/src/plugins/supportHelper.tsx b/src/plugins/supportHelper.tsx new file mode 100644 index 0000000..6cf2177 --- /dev/null +++ b/src/plugins/supportHelper.tsx @@ -0,0 +1,89 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2023 Vendicated and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. +*/ + +import { DataStore } from "@api/index"; +import { Devs, SUPPORT_CHANNEL_ID } from "@utils/constants"; +import { makeCodeblock } from "@utils/misc"; +import definePlugin from "@utils/types"; +import { isOutdated } from "@utils/updater"; +import { Alerts, FluxDispatcher, Forms, UserStore } from "@webpack/common"; + +import gitHash from "~git-hash"; +import plugins from "~plugins"; + +import settings from "./settings"; + +const REMEMBER_DISMISS_KEY = "Vencord-SupportHelper-Dismiss"; + +export default definePlugin({ + name: "SupportHelper", + required: true, + description: "Helps me provide support to you", + authors: [Devs.Ven], + + commands: [{ + name: "vencord-debug", + description: "Send Vencord Debug info", + predicate: ctx => ctx.channel.id === SUPPORT_CHANNEL_ID, + execute() { + const { RELEASE_CHANNEL } = window.GLOBAL_ENV; + + const debugInfo = ` +**Vencord Debug Info** + +> Discord Branch: ${RELEASE_CHANNEL} +> Client: ${typeof DiscordNative === "undefined" ? window.armcord ? "Armcord" : `Web (${navigator.userAgent})` : `Desktop (Electron v${settings.electronVersion})`} +> Platform: ${window.navigator.platform} +> Vencord Version: ${gitHash}${settings.additionalInfo} +> Outdated: ${isOutdated} +> Enabled Plugins: +${makeCodeblock(Object.keys(plugins).filter(Vencord.Plugins.isPluginEnabled).join(", "))} +`; + + return { + content: debugInfo.trim() + }; + } + }], + + rememberDismiss() { + DataStore.set(REMEMBER_DISMISS_KEY, gitHash); + }, + + start() { + FluxDispatcher.subscribe("CHANNEL_SELECT", async ({ channelId }) => { + if (channelId !== SUPPORT_CHANNEL_ID) return; + if (UserStore.getCurrentUser().id in Devs) return; + + if (isOutdated && gitHash !== await DataStore.get(REMEMBER_DISMISS_KEY)) { + Alerts.show({ + title: "Hold on!", + body: <div> + <Forms.FormText>You are using an outdated version of Vencord! Chances are, your issue is already fixed.</Forms.FormText> + <Forms.FormText> + Please first update using the Updater Page in Settings, or use the VencordInstaller (Update Vencord Button) + to do so, in case you can't access the Updater page. + </Forms.FormText> + </div>, + onCancel: this.rememberDismiss, + onConfirm: this.rememberDismiss + }); + } + }); + } +}); |