mirror of
https://github.com/ryanamay/Vencord.git
synced 2024-09-20 00:50:34 +00:00
BetterGifSend: fix and add option to toggle reply behavior
This commit is contained in:
parent
80da8a08be
commit
af1c5c3c47
2 changed files with 20 additions and 3 deletions
|
@ -19,3 +19,7 @@ Control how GIFs are sent:
|
|||
- **Send immediately**: Sends the GIF directly to the chat. (Default)
|
||||
- **Insert into chatbox**: Inserts the GIF URL into the chatbox, allowing you to add additional text before sending.
|
||||
- **Insert link if SHIFT is held**: Inserts the GIF URL into the chatbox if the SHIFT key is held down.
|
||||
|
||||
### Clear Reply
|
||||
|
||||
Automatically clear the reply context after sending a singular GIF.
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { insertTextIntoChatInputBox, sendMessage } from "@utils/discord";
|
||||
import { insertTextIntoChatInputBox } from "@utils/discord";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { ExpressionPickerStore, SelectedChannelStore } from "@webpack/common";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { ExpressionPickerStore, FluxDispatcher, MessageActions, SelectedChannelStore } from "@webpack/common";
|
||||
|
||||
interface Gif {
|
||||
url: string;
|
||||
|
@ -36,9 +37,17 @@ const settings = definePluginSettings({
|
|||
{ value: "Insert", label: "Insert into chatbox" },
|
||||
{ value: "InsertWithShift", label: "Insert link if SHIFT is held" }
|
||||
]
|
||||
},
|
||||
clearReply: {
|
||||
type: OptionType.BOOLEAN,
|
||||
default: true,
|
||||
description: "Clear the reply context after sending a singular GIF",
|
||||
restartNeeded: false
|
||||
}
|
||||
});
|
||||
|
||||
const PendingReplyStore = findByPropsLazy("getPendingReply");
|
||||
|
||||
let shiftHeld = false;
|
||||
|
||||
function handleShift(event: KeyboardEvent): void {
|
||||
|
@ -78,7 +87,11 @@ export default definePlugin({
|
|||
if (sendBehavior === "Insert" || (sendBehavior === "InsertWithShift" && shiftHeld)) {
|
||||
insertTextIntoChatInputBox(gif.url + " ");
|
||||
} else {
|
||||
sendMessage(channel, { content: gif.url });
|
||||
const reply = PendingReplyStore.getPendingReply(channel);
|
||||
MessageActions.sendMessage(channel, { content: gif.url }, void 0, true, MessageActions.getSendMessageOptionsForReply(reply));
|
||||
if (settings.store.clearReply && reply) {
|
||||
FluxDispatcher.dispatch({ type: "DELETE_PENDING_REPLY", channelId: channel });
|
||||
}
|
||||
}
|
||||
|
||||
if (closeBehavior === "Close" || (closeBehavior === "ShiftOpen" && !shiftHeld)) {
|
||||
|
|
Loading…
Reference in a new issue