diff --git a/packages/discord-types/src/stores/PendingReplyStore.d.ts b/packages/discord-types/src/stores/PendingReplyStore.d.ts new file mode 100644 index 00000000..687601f1 --- /dev/null +++ b/packages/discord-types/src/stores/PendingReplyStore.d.ts @@ -0,0 +1,15 @@ +import { Channel, Message } from "../common"; +import { FluxStore } from "./FluxStore"; + +export interface PendingReply { + channel: Channel; + message: Message; + shouldMention: boolean; + showMentionToggle: boolean; +} + +export class PendingReplyStore extends FluxStore { + getPendingReply(channelId: string): PendingReply | undefined; + /** Discord doesn't use this method. Also seems to always return undefined */ + getPendingReplyActionSource(channelId: string): unknown; +} diff --git a/packages/discord-types/src/stores/index.d.ts b/packages/discord-types/src/stores/index.d.ts index 12f70760..366467f1 100644 --- a/packages/discord-types/src/stores/index.d.ts +++ b/packages/discord-types/src/stores/index.d.ts @@ -23,6 +23,7 @@ export * from "./MediaEngineStore"; export * from "./MessageStore"; export * from "./NotificationSettingsStore"; export * from "./OverridePremiumTypeStore"; +export * from "./PendingReplyStore"; export * from "./PermissionStore"; export * from "./PopoutWindowStore"; export * from "./PresenceStore"; diff --git a/src/plugins/customCommands/index.ts b/src/plugins/customCommands/index.ts index e9d857bd..37edf902 100644 --- a/src/plugins/customCommands/index.ts +++ b/src/plugins/customCommands/index.ts @@ -23,6 +23,7 @@ import { migratePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import { sendMessage } from "@utils/discord"; import definePlugin from "@utils/types"; +import { FluxDispatcher, MessageActions, PendingReplyStore } from "@webpack/common"; import { openCreateTagModal } from "./CreateTagModal"; import { getTag, getTags, removeTag, settings, Tag } from "./settings"; @@ -67,7 +68,7 @@ export function registerTagCommand(tag: Tag) { } ], - execute: async (args, ctx) => { + execute: async (args, { channel }) => { const ephemeral = findOption(args, "ephemeral", false); const response = tag.message @@ -78,7 +79,8 @@ export function registerTagCommand(tag: Tag) { .replaceAll("\\n", "\n"); const doSend = ephemeral ? sendBotMessage : sendMessage; - doSend(ctx.channel.id, { content: response }); + doSend(channel.id, { content: response }, false, MessageActions.getSendMessageOptionsForReply(PendingReplyStore.getPendingReply(channel.id))); + FluxDispatcher.dispatch({ type: "DELETE_PENDING_REPLY", channelId: channel.id }); }, [CustomCommandsMarker]: true, }, "CustomCommands"); diff --git a/src/plugins/spotifyShareCommands/index.ts b/src/plugins/spotifyShareCommands/index.ts index d00d4a2c..b4a85eb1 100644 --- a/src/plugins/spotifyShareCommands/index.ts +++ b/src/plugins/spotifyShareCommands/index.ts @@ -22,7 +22,7 @@ import { sendMessage } from "@utils/discord"; import definePlugin from "@utils/types"; import { Command } from "@vencord/discord-types"; import { findByPropsLazy } from "@webpack"; -import { FluxDispatcher, MessageActions } from "@webpack/common"; +import { FluxDispatcher, MessageActions, PendingReplyStore } from "@webpack/common"; interface Album { id: string; @@ -55,7 +55,6 @@ interface Track { } const Spotify = findByPropsLazy("getPlayerState"); -const PendingReplyStore = findByPropsLazy("getPendingReply"); function makeCommand(name: string, formatUrl: (track: Track) => string): Command { return { diff --git a/src/plugins/voiceMessages/index.tsx b/src/plugins/voiceMessages/index.tsx index 6452f5ff..4d1d5460 100644 --- a/src/plugins/voiceMessages/index.tsx +++ b/src/plugins/voiceMessages/index.tsx @@ -32,8 +32,8 @@ import definePlugin from "@utils/types"; import { chooseFile } from "@utils/web"; import { CloudUpload as TCloudUpload } from "@vencord/discord-types"; import { CloudUploadPlatform } from "@vencord/discord-types/enums"; -import { findLazy, findStoreLazy } from "@webpack"; -import { Button, Constants, FluxDispatcher, Forms, lodash, Menu, MessageActions, PermissionsBits, PermissionStore, RestAPI, SelectedChannelStore, showToast, SnowflakeUtils, Toasts, useEffect, useState } from "@webpack/common"; +import { findLazy } from "@webpack"; +import { Button, Constants, FluxDispatcher, Forms, lodash, Menu, MessageActions, PendingReplyStore, PermissionsBits, PermissionStore, RestAPI, SelectedChannelStore, showToast, SnowflakeUtils, Toasts, useEffect, useState } from "@webpack/common"; import { ComponentType } from "react"; import { VoiceRecorderDesktop } from "./DesktopRecorder"; @@ -42,7 +42,6 @@ import { VoicePreview } from "./VoicePreview"; import { VoiceRecorderWeb } from "./WebRecorder"; const CloudUpload: typeof TCloudUpload = findLazy(m => m.prototype?.trackUploadFinished); -const PendingReplyStore = findStoreLazy("PendingReplyStore"); export const cl = classNameFactory("vc-vmsg-"); export type VoiceRecorder = ComponentType<{ diff --git a/src/webpack/common/stores.ts b/src/webpack/common/stores.ts index 0d43e635..31d552f8 100644 --- a/src/webpack/common/stores.ts +++ b/src/webpack/common/stores.ts @@ -36,6 +36,7 @@ export let GuildChannelStore: t.GuildChannelStore; export let ReadStateStore: t.ReadStateStore; export let PresenceStore: t.PresenceStore; export let AccessibilityStore: t.AccessibilityStore; +export let PendingReplyStore: t.PendingReplyStore; export let GuildStore: t.GuildStore; export let GuildRoleStore: t.GuildRoleStore; @@ -130,6 +131,7 @@ waitForStore("LocaleStore", m => LocaleStore = m); waitForStore("RTCConnectionStore", m => RTCConnectionStore = m); waitForStore("SoundboardStore", m => SoundboardStore = m); waitForStore("PopoutWindowStore", m => PopoutWindowStore = m); +waitForStore("PendingReplyStore", m => PendingReplyStore = m); waitForStore("ThemeStore", m => { ThemeStore = m; // Importing this directly causes all webpack commons to be imported, which can easily cause circular dependencies.