CustomCommands: fix replying with commands

This commit is contained in:
Vendicated 2026-03-15 01:04:07 +01:00 committed by End
parent 483d564782
commit 4a2c23ea24
No known key found for this signature in database
6 changed files with 25 additions and 7 deletions

View file

@ -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;
}

View file

@ -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";

View file

@ -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");

View file

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

View file

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

View file

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