From 194328fceac87f00909f0ce2bcc4d2e0874956b4 Mon Sep 17 00:00:00 2001 From: shnimlz Date: Sat, 20 Sep 2025 17:05:55 -0500 Subject: [PATCH] revert code --- .../messages/alliaces/createEmbedv2.ts | 15 ++++++++--- src/commands/messages/alliaces/editEmbedv2.ts | 14 ++++++++--- src/core/api/discordAPI.ts | 25 ------------------- 3 files changed, 21 insertions(+), 33 deletions(-) diff --git a/src/commands/messages/alliaces/createEmbedv2.ts b/src/commands/messages/alliaces/createEmbedv2.ts index 17a4e24..22011b8 100644 --- a/src/commands/messages/alliaces/createEmbedv2.ts +++ b/src/commands/messages/alliaces/createEmbedv2.ts @@ -2,7 +2,6 @@ import { CommandMessage } from "../../../core/types/commands"; // @ts-ignore import { ComponentType, ButtonStyle, ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder, Message, MessageFlags } from "discord.js"; import { replaceVars, isValidUrlOrVariable, listVariables } from "../../../core/lib/vars"; -import { patchMessageWithDisplay } from "../../../core/api/discordAPI"; /** * Botones de edición - VERSIÓN MEJORADA @@ -218,9 +217,17 @@ const renderPreview = async (blockState: any, member: any, guild: any) => { }; }; -// Helper para actualizar el editor vía REST y no filtrar display +// Helper para actualizar el editor combinando Display Container dentro de components const updateEditor = async (msg: any, data: any) => { - await patchMessageWithDisplay(msg.channelId, msg.id, data); + const container = data?.display; + const rows = Array.isArray(data?.components) ? data.components : []; + const components = container ? [container, ...rows] : rows; + const payload: any = { ...data }; + delete payload.display; + payload.components = components; + // Si no se pasa flags explícitos, usamos 32768 como en tu entorno + if (payload.flags === undefined) payload.flags = 32768; + await msg.edit(payload); }; export const command: CommandMessage = { @@ -277,7 +284,7 @@ export const command: CommandMessage = { //@ts-ignore await updateEditor(editorMessage, { content: null, - flags: 4096, + flags: 32768, display: await renderPreview(blockState, message.member, message.guild), components: btns(false) }); diff --git a/src/commands/messages/alliaces/editEmbedv2.ts b/src/commands/messages/alliaces/editEmbedv2.ts index 7223f72..486367e 100644 --- a/src/commands/messages/alliaces/editEmbedv2.ts +++ b/src/commands/messages/alliaces/editEmbedv2.ts @@ -2,7 +2,6 @@ import { CommandMessage } from "../../../core/types/commands"; // @ts-ignore import { ComponentType, ButtonStyle, ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder, MessageFlags } from "discord.js"; import { replaceVars, isValidUrlOrVariable, listVariables } from "../../../core/lib/vars"; -import { patchMessageWithDisplay } from "../../../core/api/discordAPI"; // Botones de edición (máx 5 por fila) const btns = (disabled = false) => ([ @@ -105,9 +104,16 @@ const renderPreview = async (blockState: any, member: any, guild: any) => { return { type: 17, accent_color: blockState.color ?? null, components: previewComponents }; }; -// Helper para actualizar el editor vía REST y no filtrar display +// Helper para actualizar el editor combinando Display Container dentro de components const updateEditor = async (msg: any, data: any) => { - await patchMessageWithDisplay(msg.channelId, msg.id, data); + const container = data?.display; + const rows = Array.isArray(data?.components) ? data.components : []; + const components = container ? [container, ...rows] : rows; + const payload: any = { ...data }; + delete payload.display; + payload.components = components; + if (payload.flags === undefined) payload.flags = 32768; // según formato real en tu entorno + await msg.edit(payload); }; export const command: CommandMessage = { @@ -159,7 +165,7 @@ export const command: CommandMessage = { // @ts-ignore await updateEditor(editorMessage, { content: null, - flags: 4096, + flags: 32768, display: await renderPreview(blockState, message.member, message.guild), components: btns(false) }); diff --git a/src/core/api/discordAPI.ts b/src/core/api/discordAPI.ts index a1f66f9..ad17492 100644 --- a/src/core/api/discordAPI.ts +++ b/src/core/api/discordAPI.ts @@ -97,28 +97,3 @@ export async function clearGlobalCommands(): Promise { } } -export async function patchMessageWithDisplay(channelId: string, messageId: string, data: any): Promise { - try { - // Validación mínima para ayudar a depurar - const dbg = { - hasDisplay: !!data?.display, - displayType: data?.display?.type, - compCount: Array.isArray(data?.display?.components) ? data.display.components.length : undefined, - hasComponents: Array.isArray(data?.components), - }; - // eslint-disable-next-line no-console - if (!dbg.hasDisplay) console.warn('[patchMessageWithDisplay] Enviando PATCH sin display. data.keys=', Object.keys(data || {})); - await rest.patch(Routes.channelMessage(channelId, messageId), { body: data }); - } catch (error: any) { - // eslint-disable-next-line no-console - console.error('[patchMessageWithDisplay] Error PATCH mensaje', { - channelId, - messageId, - status: error?.status, - code: error?.code, - message: error?.message, - rawError: error?.rawError, - }); - throw error; - } -}