BetterGifSend: fix and add option to toggle reply behavior

This commit is contained in:
ryana mittens 2024-09-08 21:17:51 +08:00
parent 80da8a08be
commit af1c5c3c47
2 changed files with 20 additions and 3 deletions

View file

@ -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.

View file

@ -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)) {