fix plugins sending messages

This commit is contained in:
Vendicated 2025-08-13 12:55:24 +02:00
parent 72329f901c
commit aad88fe9cd
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18
2 changed files with 9 additions and 9 deletions

View file

@ -62,7 +62,7 @@ export interface MessageReplyOptions {
};
}
export interface MessageExtra {
export interface MessageOptions {
stickers?: string[];
uploads?: Upload[];
replyOptions: MessageReplyOptions;
@ -72,17 +72,17 @@ export interface MessageExtra {
openWarningPopout: (props: any) => any;
}
export type MessageSendListener = (channelId: string, messageObj: MessageObject, extra: MessageExtra) => Promisable<void | { cancel: boolean; }>;
export type MessageSendListener = (channelId: string, messageObj: MessageObject, options: MessageOptions) => Promisable<void | { cancel: boolean; }>;
export type MessageEditListener = (channelId: string, messageId: string, messageObj: MessageObject) => Promisable<void | { cancel: boolean; }>;
const sendListeners = new Set<MessageSendListener>();
const editListeners = new Set<MessageEditListener>();
export async function _handlePreSend(channelId: string, messageObj: MessageObject, extra: MessageExtra, replyOptions: MessageReplyOptions) {
extra.replyOptions = replyOptions;
export async function _handlePreSend(channelId: string, messageObj: MessageObject, options: MessageOptions, replyOptions: MessageReplyOptions) {
options.replyOptions = replyOptions;
for (const listener of sendListeners) {
try {
const result = await listener(channelId, messageObj, extra);
const result = await listener(channelId, messageObj, options);
if (result?.cancel) {
return true;
}

View file

@ -110,7 +110,7 @@ export function insertTextIntoChatInputBox(text: string) {
});
}
interface MessageExtra {
interface MessageOptions {
messageReference: Message["messageReference"];
allowedMentions: {
parse: string[];
@ -122,8 +122,8 @@ interface MessageExtra {
export function sendMessage(
channelId: string,
data: Partial<MessageObject>,
waitForChannelReady?: boolean,
extra?: Partial<MessageExtra>
waitForChannelReady = true,
options: Partial<MessageOptions> = {}
) {
const messageData = {
content: "",
@ -133,7 +133,7 @@ export function sendMessage(
...data
};
return MessageActions.sendMessage(channelId, messageData, waitForChannelReady, extra);
return MessageActions.sendMessage(channelId, messageData, waitForChannelReady, options);
}
/**