Create index.tsx

This commit is contained in:
RyfterWasTaken 2025-01-30 14:59:23 +01:00 committed by GitHub
parent 8fccda4a24
commit e9a32a0764
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

77
src/plugins/index.tsx Normal file
View file

@ -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 (
<SettingsView settings={settings} />
);
}
},
...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]);
}
},
});