diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/emoteCloner/index.tsx | 6 | ||||
-rw-r--r-- | src/plugins/messageClickActions/README.md | 5 | ||||
-rw-r--r-- | src/plugins/messageClickActions/index.ts | 8 | ||||
-rw-r--r-- | src/plugins/quickMention/README.md | 5 | ||||
-rw-r--r-- | src/plugins/quickMention/index.tsx | 7 | ||||
-rw-r--r-- | src/plugins/quickReply/README.md | 6 | ||||
-rw-r--r-- | src/plugins/quickReply/index.ts | 25 | ||||
-rw-r--r-- | src/plugins/searchReply/index.tsx | 4 |
8 files changed, 41 insertions, 25 deletions
diff --git a/src/plugins/emoteCloner/index.tsx b/src/plugins/emoteCloner/index.tsx index 0900422..7acb6ec 100644 --- a/src/plugins/emoteCloner/index.tsx +++ b/src/plugins/emoteCloner/index.tsx @@ -24,11 +24,9 @@ import { Margins } from "@utils/margins"; import { ModalContent, ModalHeader, ModalRoot, openModalLazy } from "@utils/modal"; import definePlugin from "@utils/types"; import { findByCodeLazy, findStoreLazy } from "@webpack"; -import { EmojiStore, FluxDispatcher, Forms, GuildStore, Menu, PermissionStore, React, RestAPI, Toasts, Tooltip, UserStore } from "@webpack/common"; +import { EmojiStore, FluxDispatcher, Forms, GuildStore, Menu, PermissionsBits, PermissionStore, React, RestAPI, Toasts, Tooltip, UserStore } from "@webpack/common"; import { Promisable } from "type-fest"; -const MANAGE_EMOJIS_AND_STICKERS = 1n << 30n; - const StickersStore = findStoreLazy("StickersStore"); const uploadEmoji = findByCodeLazy('"EMOJI_UPLOAD_START"', "GUILD_EMOJIS("); @@ -120,7 +118,7 @@ function getGuildCandidates(data: Data) { return Object.values(GuildStore.getGuilds()).filter(g => { const canCreate = g.ownerId === meId || - BigInt(PermissionStore.getGuildPermissions({ id: g.id }) & MANAGE_EMOJIS_AND_STICKERS) === MANAGE_EMOJIS_AND_STICKERS; + (PermissionStore.getGuildPermissions({ id: g.id }) & PermissionsBits.CREATE_GUILD_EXPRESSIONS) === PermissionsBits.CREATE_GUILD_EXPRESSIONS; if (!canCreate) return false; if (data.t === "Sticker") return true; 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", diff --git a/src/plugins/quickMention/README.md b/src/plugins/quickMention/README.md new file mode 100644 index 0000000..fd86261 --- /dev/null +++ b/src/plugins/quickMention/README.md @@ -0,0 +1,5 @@ +# QuickMention + +Adds a mention icon to the messages action bar + +![](https://github.com/Vendicated/Vencord/assets/55940580/82d3fec7-4196-4917-b3c2-6e652b2aff9e) diff --git a/src/plugins/quickMention/index.tsx b/src/plugins/quickMention/index.tsx index d0699b9..9720c7d 100644 --- a/src/plugins/quickMention/index.tsx +++ b/src/plugins/quickMention/index.tsx @@ -20,7 +20,7 @@ import { addButton, removeButton } from "@api/MessagePopover"; import { Devs } from "@utils/constants"; import { insertTextIntoChatInputBox } from "@utils/discord"; import definePlugin from "@utils/types"; -import { ChannelStore } from "@webpack/common"; +import { ChannelStore, PermissionsBits, PermissionStore } from "@webpack/common"; export default definePlugin({ name: "QuickMention", @@ -30,11 +30,14 @@ export default definePlugin({ start() { addButton("QuickMention", msg => { + const channel = ChannelStore.getChannel(msg.channel_id); + if (!PermissionStore.can(PermissionsBits.SEND_MESSAGES, channel)) return null; + return { label: "Quick Mention", icon: this.Icon, message: msg, - channel: ChannelStore.getChannel(msg.channel_id), + channel, onClick: () => insertTextIntoChatInputBox(`<@${msg.author.id}> `) }; }); 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 + +![](https://github.com/Vendicated/Vencord/assets/55940580/df79a27a-6529-4c70-8870-3c17d3637e4f) + 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); } diff --git a/src/plugins/searchReply/index.tsx b/src/plugins/searchReply/index.tsx index 9e53436..3f5c643 100644 --- a/src/plugins/searchReply/index.tsx +++ b/src/plugins/searchReply/index.tsx @@ -21,7 +21,7 @@ import { Devs } from "@utils/constants"; import { LazyComponent } from "@utils/react"; import definePlugin from "@utils/types"; import { findByCode, findByCodeLazy } from "@webpack"; -import { ChannelStore, i18n, Menu, SelectedChannelStore } from "@webpack/common"; +import { ChannelStore, i18n, Menu, PermissionsBits, PermissionStore, SelectedChannelStore } from "@webpack/common"; import { Message } from "discord-types/general"; const ReplyIcon = LazyComponent(() => findByCode("M10 8.26667V4L3 11.4667L10 18.9333V14.56C15 14.56 18.5 16.2667 21 20C20 14.6667 17 9.33333 10 8.26667Z")); @@ -31,9 +31,9 @@ const replyFn = findByCodeLazy("showMentionToggle", "TEXTAREA_FOCUS", "shiftKey" const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { message }: { message: Message; }) => () => { // make sure the message is in the selected channel if (SelectedChannelStore.getChannelId() !== message.channel_id) return; - const channel = ChannelStore.getChannel(message?.channel_id); if (!channel) return; + if (!PermissionStore.can(PermissionsBits.SEND_MESSAGES, channel)) return; // dms and group chats const dmGroup = findGroupChildrenByChildId("pin", children); |