aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/messageClickActions
diff options
context:
space:
mode:
authorHugo C <lumap@duck.com>2023-09-24 16:42:53 +0200
committerGitHub <noreply@github.com>2023-09-24 16:42:53 +0200
commit044f64e446b67613282fa96192abe6d1ed504923 (patch)
treef4e076f06fbf20b56b41907d008ae97b49322808 /src/plugins/messageClickActions
parent0b7fca864af6b99800e5a005e45ec8a527c54fb9 (diff)
downloadVencord-044f64e446b67613282fa96192abe6d1ed504923.tar.gz
Vencord-044f64e446b67613282fa96192abe6d1ed504923.tar.bz2
Vencord-044f64e446b67613282fa96192abe6d1ed504923.zip
Improve permission checks on several plugins (#1746)
Co-authored-by: V <vendicated@riseup.net>
Diffstat (limited to 'src/plugins/messageClickActions')
-rw-r--r--src/plugins/messageClickActions/README.md5
-rw-r--r--src/plugins/messageClickActions/index.ts8
2 files changed, 9 insertions, 4 deletions
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",