ni yo se que hice xd

This commit is contained in:
2025-09-20 16:35:38 -05:00
parent bb30b90bea
commit b57b104a85
3 changed files with 40 additions and 34 deletions

View File

@@ -2,6 +2,7 @@ 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) => ([
@@ -104,6 +105,11 @@ 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
const updateEditor = async (msg: any, data: any) => {
await patchMessageWithDisplay(msg.channelId, msg.id, data);
};
export const command: CommandMessage = {
name: "editar-embed",
type: "message",
@@ -151,10 +157,9 @@ export const command: CommandMessage = {
await new Promise(r => setTimeout(r, 3000));
// @ts-ignore
await editorMessage.edit({
await updateEditor(editorMessage, {
content: null,
flags: 4096,
// @ts-ignore - Display Components
display: await renderPreview(blockState, message.member, message.guild),
components: btns(false)
});
@@ -174,7 +179,7 @@ export const command: CommandMessage = {
where: { guildId_name: { guildId: message.guildId!, name: blockName } },
data: { config: blockState }
});
await editorMessage.edit({
await updateEditor(editorMessage, {
// @ts-ignore
display: {
type: 17,
@@ -263,7 +268,7 @@ export const command: CommandMessage = {
} else if (b.customId === 'delete_cover') {
blockState.coverImage = null;
await b.update({ content: '✅ Imagen de portada eliminada.', components: [] });
await editorMessage.edit({ // @ts-ignore
await updateEditor(editorMessage, { // @ts-ignore
display: await renderPreview(blockState, message.member, message.guild),
components: btns(false)
});
@@ -316,7 +321,7 @@ export const command: CommandMessage = {
}
await b.update({ content: '✅ Bloque movido abajo.', components: [] });
}
await editorMessage.edit({ // @ts-ignore
await updateEditor(editorMessage, { // @ts-ignore
display: await renderPreview(blockState, message.member, message.guild),
components: btns(false)
});
@@ -354,7 +359,7 @@ export const command: CommandMessage = {
blockState.components.splice(idx, 1);
await sel.update({ content: '✅ Elemento eliminado.', components: [] });
}
await editorMessage.edit({ // @ts-ignore
await updateEditor(editorMessage, { // @ts-ignore
display: await renderPreview(blockState, message.member, message.guild),
components: btns(false)
});
@@ -408,7 +413,7 @@ export const command: CommandMessage = {
const duplicatedComponent = JSON.parse(JSON.stringify(originalComponent));
blockState.components.splice(idx + 1, 0, duplicatedComponent);
await sel.update({ content: '✅ Elemento duplicado.', components: [] });
await editorMessage.edit({ // @ts-ignore
await updateEditor(editorMessage, { // @ts-ignore
display: await renderPreview(blockState, message.member, message.guild),
components: btns(false)
});
@@ -519,7 +524,7 @@ export const command: CommandMessage = {
} else if (b.customId.startsWith('delete_link_button_')) {
delete textComp.linkButton;
await b.update({ content: '✅ Botón link eliminado.', components: [] });
await editorMessage.edit({ // @ts-ignore
await updateEditor(editorMessage, { // @ts-ignore
display: await renderPreview(blockState, message.member, message.guild),
components: btns(false)
});
@@ -543,7 +548,7 @@ export const command: CommandMessage = {
}
}
await editorMessage.edit({ // @ts-ignore
await updateEditor(editorMessage, { // @ts-ignore
display: await renderPreview(blockState, message.member, message.guild),
components: btns(false)
});
@@ -626,7 +631,7 @@ export const command: CommandMessage = {
try {
const exists = await editorMessage.fetch().catch(() => null);
if (!exists) return;
await editorMessage.edit({ // @ts-ignore
await updateEditor(editorMessage, { // @ts-ignore
display: await renderPreview(blockState, message.member, message.guild),
components: btns(false)
});
@@ -643,7 +648,7 @@ export const command: CommandMessage = {
try {
const exists = await editorMessage.fetch().catch(() => null);
if (exists) {
await editorMessage.edit({ // @ts-ignore
await updateEditor(editorMessage, { // @ts-ignore
display: { type: 17, components: [{ type: 10, content: '⏰ Editor finalizado por inactividad.' }] },
components: []
});