From 044f64e446b67613282fa96192abe6d1ed504923 Mon Sep 17 00:00:00 2001 From: Hugo C Date: Sun, 24 Sep 2023 16:42:53 +0200 Subject: Improve permission checks on several plugins (#1746) Co-authored-by: V --- src/plugins/messageClickActions/README.md | 5 +++++ src/plugins/messageClickActions/index.ts | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 src/plugins/messageClickActions/README.md (limited to 'src/plugins/messageClickActions') diff --git a/src/plugins/messageClickActions/README.md b/src/plugins/messageClickActions/README.md new file mode 100644 index 0000000..5162105 --- /dev/null +++ b/src/plugins/messageClickActions/README.md @@ -0,0 +1,5 @@ +# MessageClickActions + +Allows you to double click to edit/reply to a message or delete it if you hold the backspace key + +![](https://github.com/Vendicated/Vencord/assets/55940580/6885aca2-4021-4910-b636-bb40f877a816) diff --git a/src/plugins/messageClickActions/index.ts b/src/plugins/messageClickActions/index.ts index 5fd6a49..128cb7c 100644 --- a/src/plugins/messageClickActions/index.ts +++ b/src/plugins/messageClickActions/index.ts @@ -21,18 +21,17 @@ import { definePluginSettings, Settings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy } from "@webpack"; -import { FluxDispatcher, PermissionStore, UserStore } from "@webpack/common"; +import { FluxDispatcher, PermissionsBits, PermissionStore, UserStore } from "@webpack/common"; let isDeletePressed = false; const keydown = (e: KeyboardEvent) => e.key === "Backspace" && (isDeletePressed = true); const keyup = (e: KeyboardEvent) => e.key === "Backspace" && (isDeletePressed = false); -const MANAGE_CHANNELS = 1n << 4n; const settings = definePluginSettings({ enableDeleteOnClick: { type: OptionType.BOOLEAN, - description: "Enable delete on click", + description: "Enable delete on click while holding backspace", default: true }, enableDoubleClickToEdit: { @@ -72,6 +71,7 @@ export default definePlugin({ if (!isDeletePressed) { if (event.detail < 2) return; if (settings.store.requireModifier && !event.ctrlKey && !event.shiftKey) return; + if (!PermissionStore.can(PermissionsBits.SEND_MESSAGES, channel)) return; if (isMe) { if (!settings.store.enableDoubleClickToEdit || EditStore.isEditing(channel.id, msg.id)) return; @@ -89,7 +89,7 @@ export default definePlugin({ showMentionToggle: channel.guild_id !== null }); } - } else if (settings.store.enableDeleteOnClick && (isMe || PermissionStore.can(MANAGE_CHANNELS, channel))) { + } else if (settings.store.enableDeleteOnClick && (isMe || PermissionStore.can(PermissionsBits.MANAGE_MESSAGES, channel))) { if (msg.deleted) { FluxDispatcher.dispatch({ type: "MESSAGE_DELETE", -- cgit