diff options
| author | Hugo C <lumap@duck.com> | 2023-09-24 16:42:53 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-24 16:42:53 +0200 |
| commit | 044f64e446b67613282fa96192abe6d1ed504923 (patch) | |
| tree | f4e076f06fbf20b56b41907d008ae97b49322808 /src/plugins/quickReply | |
| parent | 0b7fca864af6b99800e5a005e45ec8a527c54fb9 (diff) | |
| download | Vencord-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/quickReply')
| -rw-r--r-- | src/plugins/quickReply/README.md | 6 | ||||
| -rw-r--r-- | src/plugins/quickReply/index.ts | 25 |
2 files changed, 18 insertions, 13 deletions
diff --git a/src/plugins/quickReply/README.md b/src/plugins/quickReply/README.md new file mode 100644 index 0000000..bd30679 --- /dev/null +++ b/src/plugins/quickReply/README.md @@ -0,0 +1,6 @@ +# QuickReply + +Reply to (ctrl + up/down) and edit (ctrl + shift + up/down) messages via keybinds + + + diff --git a/src/plugins/quickReply/index.ts b/src/plugins/quickReply/index.ts index 06797bc..7a39ec0 100644 --- a/src/plugins/quickReply/index.ts +++ b/src/plugins/quickReply/index.ts @@ -20,7 +20,7 @@ import { definePluginSettings, Settings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy } from "@webpack"; -import { ChannelStore, FluxDispatcher as Dispatcher, MessageStore, SelectedChannelStore, UserStore } from "@webpack/common"; +import { ChannelStore, FluxDispatcher as Dispatcher, MessageStore, PermissionsBits, PermissionStore, SelectedChannelStore, UserStore } from "@webpack/common"; import { Message } from "discord-types/general"; const Kangaroo = findByPropsLazy("jumpToMessage"); @@ -172,6 +172,7 @@ function shouldMention(message) { // handle next/prev reply function nextReply(isUp: boolean) { + if (!PermissionStore.can(PermissionsBits.SEND_MESSAGES, ChannelStore.getChannel(SelectedChannelStore.getChannelId()))) return; const message = getNextMessage(isUp, true); if (!message) @@ -179,7 +180,6 @@ function nextReply(isUp: boolean) { type: "DELETE_PENDING_REPLY", channelId: SelectedChannelStore.getChannelId(), }); - const channel = ChannelStore.getChannel(message.channel_id); const meId = UserStore.getCurrentUser().id; @@ -196,21 +196,20 @@ function nextReply(isUp: boolean) { // handle next/prev edit function nextEdit(isUp: boolean) { + if (!PermissionStore.can(PermissionsBits.SEND_MESSAGES, ChannelStore.getChannel(SelectedChannelStore.getChannelId()))) return; const message = getNextMessage(isUp, false); if (!message) - Dispatcher.dispatch({ + return Dispatcher.dispatch({ type: "MESSAGE_END_EDIT", channelId: SelectedChannelStore.getChannelId() }); - else { - Dispatcher.dispatch({ - type: "MESSAGE_START_EDIT", - channelId: message.channel_id, - messageId: message.id, - content: message.content, - _isQuickEdit: true - }); - jumpIfOffScreen(message.channel_id, message.id); - } + Dispatcher.dispatch({ + type: "MESSAGE_START_EDIT", + channelId: message.channel_id, + messageId: message.id, + content: message.content, + _isQuickEdit: true + }); + jumpIfOffScreen(message.channel_id, message.id); } |
