mirror of
https://github.com/System-End/Vencord.git
synced 2026-04-19 15:18:21 +00:00
CustomCommands: fix replying with commands
This commit is contained in:
parent
483d564782
commit
4a2c23ea24
6 changed files with 25 additions and 7 deletions
15
packages/discord-types/src/stores/PendingReplyStore.d.ts
vendored
Normal file
15
packages/discord-types/src/stores/PendingReplyStore.d.ts
vendored
Normal 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;
|
||||
}
|
||||
1
packages/discord-types/src/stores/index.d.ts
vendored
1
packages/discord-types/src/stores/index.d.ts
vendored
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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<{
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue