aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/voiceMessages/index.tsx14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/plugins/voiceMessages/index.tsx b/src/plugins/voiceMessages/index.tsx
index be5a3f3..b5b9c73 100644
--- a/src/plugins/voiceMessages/index.tsx
+++ b/src/plugins/voiceMessages/index.tsx
@@ -26,8 +26,8 @@ import { ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, openModa
import { useAwaiter } from "@utils/react";
import definePlugin from "@utils/types";
import { chooseFile } from "@utils/web";
-import { findLazy } from "@webpack";
-import { Button, Forms, Menu, PermissionsBits, PermissionStore, RestAPI, SelectedChannelStore, showToast, SnowflakeUtils, Toasts, useEffect, useState } from "@webpack/common";
+import { findByPropsLazy, findLazy, findStoreLazy } from "@webpack";
+import { Button, FluxDispatcher, Forms, Menu, PermissionsBits, PermissionStore, RestAPI, SelectedChannelStore, showToast, SnowflakeUtils, Toasts, useEffect, useState } from "@webpack/common";
import { ComponentType } from "react";
import { VoiceRecorderDesktop } from "./DesktopRecorder";
@@ -37,6 +37,8 @@ import { VoicePreview } from "./VoicePreview";
import { VoiceRecorderWeb } from "./WebRecorder";
const CloudUpload = findLazy(m => m.prototype?.uploadFileToCloud);
+const MessageCreator = findByPropsLazy("getSendMessageOptionsForReply", "sendMessage");
+const PendingReplyStore = findStoreLazy("PendingReplyStore");
export type VoiceRecorder = ComponentType<{
setAudioBlob(blob: Blob): void;
@@ -48,7 +50,7 @@ const VoiceRecorder = IS_DISCORD_DESKTOP ? VoiceRecorderDesktop : VoiceRecorderW
export default definePlugin({
name: "VoiceMessages",
description: "Allows you to send voice messages like on mobile. To do so, right click the upload button and click Send Voice Message",
- authors: [Devs.Ven, Devs.Vap],
+ authors: [Devs.Ven, Devs.Vap, Devs.Nickyux],
settings,
start() {
@@ -71,6 +73,8 @@ const EMPTY_META: AudioMetadata = {
function sendAudio(blob: Blob, meta: AudioMetadata) {
const channelId = SelectedChannelStore.getChannelId();
+ const reply = PendingReplyStore.getPendingReply(channelId);
+ if (reply) FluxDispatcher.dispatch({ type: "DELETE_PENDING_REPLY", channelId });
const upload = new CloudUpload({
file: new File([blob], "voice-message.ogg", { type: "audio/ogg; codecs=opus" }),
@@ -95,7 +99,8 @@ function sendAudio(blob: Blob, meta: AudioMetadata) {
uploaded_filename: upload.uploadedFilename,
waveform: meta.waveform,
duration_secs: meta.duration,
- }]
+ }],
+ message_reference: reply ? MessageCreator.getSendMessageOptionsForReply(reply)?.messageReference : null,
}
});
});
@@ -232,4 +237,3 @@ const ctxMenuPatch: NavContextMenuPatchCallback = (children, props) => () => {
/>
);
};
-