Fix consoleShortcuts for web

This commit is contained in:
Vendicated 2022-10-05 14:25:37 +02:00
parent 7e526e4172
commit 3e0355cb53
No known key found for this signature in database
GPG key ID: EC781ADFB93EFFA3

View file

@ -1,6 +1,10 @@
import { Devs } from "../utils/constants"; import { Devs } from "../utils/constants";
import definePlugin from "../utils/types"; import definePlugin from "../utils/types";
const WEB_ONLY = (f: string) => () => {
throw new Error(`'${f}' is Discord Desktop only.`);
};
export default definePlugin({ export default definePlugin({
name: "ConsoleShortcuts", name: "ConsoleShortcuts",
description: "Adds shorter Aliases for many things on the window. Run `shortcutList` for a list.", description: "Adds shorter Aliases for many things on the window. Run `shortcutList` for a list.",
@ -8,8 +12,8 @@ export default definePlugin({
getShortcuts() { getShortcuts() {
return { return {
toClip: window.DiscordNative.clipboard.copy, toClip: IS_WEB ? WEB_ONLY("toClip") : window.DiscordNative.clipboard.copy,
fromClip: window.DiscordNative.clipboard.read, fromClip: IS_WEB ? WEB_ONLY("fromClip") : window.DiscordNative.clipboard.read,
wp: Vencord.Webpack, wp: Vencord.Webpack,
wpc: Vencord.Webpack.wreq.c, wpc: Vencord.Webpack.wreq.c,
wreq: Vencord.Webpack.wreq, wreq: Vencord.Webpack.wreq,
@ -22,7 +26,7 @@ export default definePlugin({
Settings: Vencord.Settings, Settings: Vencord.Settings,
Api: Vencord.Api, Api: Vencord.Api,
reload: () => location.reload(), reload: () => location.reload(),
restart: () => window.DiscordNative.app.relaunch() restart: IS_WEB ? WEB_ONLY("restart") : window.DiscordNative.app.relaunch
}; };
}, },