From e9a32a07646aad3523e25b4b5ecb7804de27a928 Mon Sep 17 00:00:00 2001 From: RyfterWasTaken <144800123+RyfterWasTaken@users.noreply.github.com> Date: Thu, 30 Jan 2025 14:59:23 +0100 Subject: [PATCH] Create index.tsx --- src/plugins/index.tsx | 77 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/plugins/index.tsx diff --git a/src/plugins/index.tsx b/src/plugins/index.tsx new file mode 100644 index 000000000..97f081e76 --- /dev/null +++ b/src/plugins/index.tsx @@ -0,0 +1,77 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2025 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +/* + * Vencord, a Discord client mod + * Copyright (c) 2025 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { definePluginSettings } from "@api/Settings"; +import definePlugin, { OptionType } from "@utils/types"; + +import { keybinds } from "./components/keybinds"; +import { SettingsView } from "./components/SettingsView"; + +const defaultSettings = {}; +for (const keybind in keybinds) { + defaultSettings[keybind] = { + type: OptionType.CUSTOM, + default: keybinds[keybind].default, + }; +} + +const settings = definePluginSettings({ + keybinds: { + type: OptionType.COMPONENT, + component: () => { + return ( + + ); + } + }, + ...defaultSettings, +}); + +export default definePlugin({ + name: "Keybinds", + description: "Bind keys to commands.", + authors: [ + { + name: "Ryfter", + id: 0n, + } + ], + settings, + start() { + document.addEventListener("keydown", this.event); + }, + stop() { + document.removeEventListener("keydown", this.event); + }, + event(e: KeyboardEvent) { + for (const keybind in keybinds) { + const { + enabled, + key, + ctrl, + alt, + shift, + } = settings.store[keybind]; + const str: string = "e"; + if ( + enabled && + alt === e.altKey && + ctrl === e.ctrlKey && + shift === e.shiftKey && + key.toUpperCase() === e.key + ) keybinds[keybind].action(); + console.log(keybinds[keybind]); + } + }, +}); + +