revert code

This commit is contained in:
2025-09-20 17:25:39 -05:00
parent 194328fcea
commit ecf2eb5599
2 changed files with 63 additions and 59 deletions

View File

@@ -454,7 +454,7 @@ export const command: CommandMessage = {
if (blockState.coverImage) { if (blockState.coverImage) {
// Si ya tiene portada, preguntar si editar o eliminar // Si ya tiene portada, preguntar si editar o eliminar
//@ts-ignore //@ts-ignore
const reply = await i.reply({ await i.reply({
flags: 64, // MessageFlags.Ephemeral flags: 64, // MessageFlags.Ephemeral
content: "Ya tienes una imagen de portada. ¿Qué quieres hacer?", content: "Ya tienes una imagen de portada. ¿Qué quieres hacer?",
components: [ components: [
@@ -465,12 +465,14 @@ export const command: CommandMessage = {
{ type: 2, style: ButtonStyle.Danger, label: "🗑️ Eliminar", custom_id: "delete_cover" } { type: 2, style: ButtonStyle.Danger, label: "🗑️ Eliminar", custom_id: "delete_cover" }
] ]
} }
], ]
fetchReply: true
}); });
// @ts-ignore // @ts-ignore
const coverCollector = reply.createMessageComponentCollector({ const replyMsg = await i.fetchReply();
//@ts-ignore
const coverCollector = replyMsg.createMessageComponentCollector({
componentType: ComponentType.Button, componentType: ComponentType.Button,
max: 1, max: 1,
time: 60000, time: 60000,
@@ -558,12 +560,14 @@ export const command: CommandMessage = {
{ type: 3, custom_id: "move_block_select", placeholder: "Elige un bloque", options } { type: 3, custom_id: "move_block_select", placeholder: "Elige un bloque", options }
] ]
} }
], ]
fetchReply: true
}); });
// Obtener el mensaje asociado (compatibilidad con djs)
// @ts-ignore
const replyMsg = await i.fetchReply();
// @ts-ignore // @ts-ignore
const selCollector = reply.createMessageComponentCollector({ const selCollector = replyMsg.createMessageComponentCollector({
componentType: ComponentType.StringSelect, componentType: ComponentType.StringSelect,
max: 1, max: 1,
time: 60000, time: 60000,
@@ -587,7 +591,7 @@ export const command: CommandMessage = {
}); });
//@ts-ignore //@ts-ignore
const btnCollector = reply.createMessageComponentCollector({ const btnCollector = replyMsg.createMessageComponentCollector({
componentType: ComponentType.Button, componentType: ComponentType.Button,
max: 1, max: 1,
time: 60000, time: 60000,
@@ -677,12 +681,12 @@ export const command: CommandMessage = {
{ type: 3, custom_id: "delete_block_select", placeholder: "Elige un elemento", options } { type: 3, custom_id: "delete_block_select", placeholder: "Elige un elemento", options }
] ]
} }
], ]
fetchReply: true
}); });
// @ts-ignore // @ts-ignore
const selCollector = reply.createMessageComponentCollector({ const replyMsg = await i.fetchReply();
// @ts-ignore
const selCollector = replyMsg.createMessageComponentCollector({
componentType: ComponentType.StringSelect, componentType: ComponentType.StringSelect,
max: 1, max: 1,
time: 60000, time: 60000,
@@ -773,12 +777,12 @@ export const command: CommandMessage = {
placeholder: "Elige un elemento", placeholder: "Elige un elemento",
options options
}] }]
}], }]
fetchReply: true
}); });
// @ts-ignore // @ts-ignore
const selCollector = reply.createMessageComponentCollector({ const replyMsg = await i.fetchReply();
// @ts-ignore
const selCollector = replyMsg.createMessageComponentCollector({
componentType: ComponentType.StringSelect, componentType: ComponentType.StringSelect,
max: 1, max: 1,
time: 60000, time: 60000,
@@ -900,12 +904,12 @@ export const command: CommandMessage = {
content: "Elige el TextDisplay a editar su thumbnail:", content: "Elige el TextDisplay a editar su thumbnail:",
components: [ components: [
{ type: 1, components: [ { type: 3, custom_id: 'choose_text_for_thumbnail', placeholder: 'Selecciona un bloque de texto', options } ] } { type: 1, components: [ { type: 3, custom_id: 'choose_text_for_thumbnail', placeholder: 'Selecciona un bloque de texto', options } ] }
], ]
fetchReply: true
}); });
// @ts-ignore // @ts-ignore
const selCollector = reply.createMessageComponentCollector({ const replyMsg = await i.fetchReply();
// @ts-ignore
const selCollector = replyMsg.createMessageComponentCollector({
componentType: ComponentType.StringSelect, componentType: ComponentType.StringSelect,
max: 1, max: 1,
time: 60000, time: 60000,
@@ -934,7 +938,7 @@ export const command: CommandMessage = {
await sel.update({ content: 'Abriendo modal…', components: [] }); await sel.update({ content: 'Abriendo modal…', components: [] });
// @ts-ignore // @ts-ignore
await i.showModal(modal); await sel.showModal(modal);
}); });
break; break;
} }
@@ -963,17 +967,12 @@ export const command: CommandMessage = {
content: "Elige el TextDisplay donde agregar/editar el botón link:", content: "Elige el TextDisplay donde agregar/editar el botón link:",
components: [ components: [
{ type: 1, components: [ { type: 3, custom_id: 'choose_text_for_linkbtn', placeholder: 'Selecciona un bloque de texto', options } ] } { type: 1, components: [ { type: 3, custom_id: 'choose_text_for_linkbtn', placeholder: 'Selecciona un bloque de texto', options } ] }
], ]
fetchReply: true
}); });
// @ts-ignore // @ts-ignore
const selCollector = reply.createMessageComponentCollector({ const replyMsg = await i.fetchReply();
componentType: ComponentType.StringSelect, // @ts-ignore
max: 1, const selCollector = replyMsg.createMessageComponentCollector({ componentType: ComponentType.StringSelect, max: 1, time: 60000, filter: (it: any) => it.user.id === message.author.id });
time: 60000,
filter: (it: any) => it.user.id === message.author.id
});
selCollector.on('collect', async (sel: any) => { selCollector.on('collect', async (sel: any) => {
const idx = parseInt(sel.values[0]); const idx = parseInt(sel.values[0]);
@@ -995,17 +994,10 @@ export const command: CommandMessage = {
{ type: 2, style: ButtonStyle.Primary, label: '✏️ Editar', custom_id: `edit_link_button_modal_${idx}` }, { type: 2, style: ButtonStyle.Primary, label: '✏️ Editar', custom_id: `edit_link_button_modal_${idx}` },
{ type: 2, style: ButtonStyle.Danger, label: '🗑️ Eliminar', custom_id: `delete_link_button_${idx}` } { type: 2, style: ButtonStyle.Danger, label: '🗑️ Eliminar', custom_id: `delete_link_button_${idx}` }
]} ]}
], ]
fetchReply: true
}); });
// @ts-ignore // @ts-ignore
const btnCollector = sub.createMessageComponentCollector({ const btnCollector = sub.createMessageComponentCollector({ componentType: ComponentType.Button, max: 1, time: 60000, filter: (b: any) => b.user.id === message.author.id });
componentType: ComponentType.Button,
max: 1,
time: 60000,
filter: (b: any) => b.user.id === message.author.id
});
btnCollector.on('collect', async (b: any) => { btnCollector.on('collect', async (b: any) => {
if (b.customId.startsWith('edit_link_button_modal_')) { if (b.customId.startsWith('edit_link_button_modal_')) {
@@ -1047,7 +1039,7 @@ export const command: CommandMessage = {
await b.update({ content: 'Abriendo modal…', components: [] }); await b.update({ content: 'Abriendo modal…', components: [] });
// @ts-ignore // @ts-ignore
await i.showModal(modal); await b.showModal(modal);
} else if (b.customId.startsWith('delete_link_button_')) { } else if (b.customId.startsWith('delete_link_button_')) {
delete textComp.linkButton; delete textComp.linkButton;
await b.update({ content: '✅ Botón link eliminado.', components: [] }); await b.update({ content: '✅ Botón link eliminado.', components: [] });
@@ -1093,7 +1085,7 @@ export const command: CommandMessage = {
await sel.update({ content: 'Abriendo modal…', components: [] }); await sel.update({ content: 'Abriendo modal…', components: [] });
// @ts-ignore // @ts-ignore
await i.showModal(modal); await sel.showModal(modal);
} }
}); });

View File

@@ -260,9 +260,11 @@ export const command: CommandMessage = {
const reply = await i.reply({ flags: 64, content: "Ya tienes una imagen de portada. ¿Qué quieres hacer?", components: [{ type: 1, components: [ const reply = await i.reply({ flags: 64, content: "Ya tienes una imagen de portada. ¿Qué quieres hacer?", components: [{ type: 1, components: [
{ type: 2, style: ButtonStyle.Primary, label: "✏️ Editar", custom_id: "edit_cover_modal" }, { type: 2, style: ButtonStyle.Primary, label: "✏️ Editar", custom_id: "edit_cover_modal" },
{ type: 2, style: ButtonStyle.Danger, label: "🗑️ Eliminar", custom_id: "delete_cover" } { type: 2, style: ButtonStyle.Danger, label: "🗑️ Eliminar", custom_id: "delete_cover" }
] }], fetchReply: true }); ] }] });
// @ts-ignore // @ts-ignore
const coverCollector = reply.createMessageComponentCollector({ componentType: ComponentType.Button, max: 1, time: 60000, filter: (b: any) => b.user.id === message.author.id }); const replyMsg = await i.fetchReply();
// @ts-ignore
const coverCollector = replyMsg.createMessageComponentCollector({ componentType: ComponentType.Button, max: 1, time: 60000, filter: (b: any) => b.user.id === message.author.id });
coverCollector.on('collect', async (b: any) => { coverCollector.on('collect', async (b: any) => {
if (b.customId === 'edit_cover_modal') { if (b.customId === 'edit_cover_modal') {
const modal = new ModalBuilder().setCustomId('edit_cover_modal').setTitle('🖼️ Editar Imagen de Portada'); const modal = new ModalBuilder().setCustomId('edit_cover_modal').setTitle('🖼️ Editar Imagen de Portada');
@@ -298,9 +300,11 @@ export const command: CommandMessage = {
description: c.type === 10 && (c.thumbnail || c.linkButton) ? (c.thumbnail ? 'Con thumbnail' : 'Con botón link') : undefined description: c.type === 10 && (c.thumbnail || c.linkButton) ? (c.thumbnail ? 'Con thumbnail' : 'Con botón link') : undefined
})); }));
// @ts-ignore // @ts-ignore
const reply = await i.reply({ flags: 64, content: 'Selecciona el bloque que quieres mover:', components: [{ type: 1, components: [ { type: 3, custom_id: 'move_block_select', placeholder: 'Elige un bloque', options } ] }], fetchReply: true }); const reply = await i.reply({ flags: 64, content: 'Selecciona el bloque que quieres mover:', components: [{ type: 1, components: [ { type: 3, custom_id: 'move_block_select', placeholder: 'Elige un bloque', options } ] }] });
// @ts-ignore // @ts-ignore
const selCollector = reply.createMessageComponentCollector({ componentType: ComponentType.StringSelect, max: 1, time: 60000, filter: (it: any) => it.user.id === message.author.id }); const replyMsg = await i.fetchReply();
// @ts-ignore
const selCollector = replyMsg.createMessageComponentCollector({ componentType: ComponentType.StringSelect, max: 1, time: 60000, filter: (it: any) => it.user.id === message.author.id });
selCollector.on('collect', async (sel: any) => { selCollector.on('collect', async (sel: any) => {
const idx = parseInt(sel.values[0]); const idx = parseInt(sel.values[0]);
await sel.update({ content: '¿Quieres mover este bloque?', components: [{ type: 1, components: [ await sel.update({ content: '¿Quieres mover este bloque?', components: [{ type: 1, components: [
@@ -308,7 +312,7 @@ export const command: CommandMessage = {
{ type: 2, style: ButtonStyle.Secondary, label: '⬇️ Bajar', custom_id: `move_down_${idx}`, disabled: idx === blockState.components.length - 1 } { type: 2, style: ButtonStyle.Secondary, label: '⬇️ Bajar', custom_id: `move_down_${idx}`, disabled: idx === blockState.components.length - 1 }
] }] }); ] }] });
// @ts-ignore // @ts-ignore
const btnCollector = reply.createMessageComponentCollector({ componentType: ComponentType.Button, max: 1, time: 60000, filter: (b: any) => b.user.id === message.author.id }); const btnCollector = replyMsg.createMessageComponentCollector({ componentType: ComponentType.Button, max: 1, time: 60000, filter: (b: any) => b.user.id === message.author.id });
btnCollector.on('collect', async (b: any) => { btnCollector.on('collect', async (b: any) => {
if (b.customId.startsWith('move_up_')) { if (b.customId.startsWith('move_up_')) {
const i2 = parseInt(b.customId.replace('move_up_', '')); const i2 = parseInt(b.customId.replace('move_up_', ''));
@@ -352,9 +356,11 @@ export const command: CommandMessage = {
break; break;
} }
// @ts-ignore // @ts-ignore
const reply = await i.reply({ flags: 64, content: 'Selecciona el elemento que quieres eliminar:', components: [{ type: 1, components: [ { type: 3, custom_id: 'delete_block_select', placeholder: 'Elige un elemento', options } ] }], fetchReply: true }); const reply = await i.reply({ flags: 64, content: 'Selecciona el elemento que quieres eliminar:', components: [{ type: 1, components: [ { type: 3, custom_id: 'delete_block_select', placeholder: 'Elige un elemento', options } ] }] });
// @ts-ignore // @ts-ignore
const selCollector = reply.createMessageComponentCollector({ componentType: ComponentType.StringSelect, max: 1, time: 60000, filter: (it: any) => it.user.id === message.author.id }); const replyMsg = await i.fetchReply();
// @ts-ignore
const selCollector = replyMsg.createMessageComponentCollector({ componentType: ComponentType.StringSelect, max: 1, time: 60000, filter: (it: any) => it.user.id === message.author.id });
selCollector.on('collect', async (sel: any) => { selCollector.on('collect', async (sel: any) => {
const selectedValue = sel.values[0]; const selectedValue = sel.values[0];
if (selectedValue === 'cover_image') { if (selectedValue === 'cover_image') {
@@ -412,7 +418,9 @@ export const command: CommandMessage = {
// @ts-ignore // @ts-ignore
const reply = await i.reply({ flags: 64, content: 'Selecciona el elemento que quieres duplicar:', components: [{ type: 1, components: [{ type: 3, custom_id: 'duplicate_select', placeholder: 'Elige un elemento', options }] }], fetchReply: true }); const reply = await i.reply({ flags: 64, content: 'Selecciona el elemento que quieres duplicar:', components: [{ type: 1, components: [{ type: 3, custom_id: 'duplicate_select', placeholder: 'Elige un elemento', options }] }], fetchReply: true });
// @ts-ignore // @ts-ignore
const selCollector = reply.createMessageComponentCollector({ componentType: ComponentType.StringSelect, max: 1, time: 60000, filter: (sel: any) => sel.user.id === message.author.id }); const replyMsg = await i.fetchReply();
// @ts-ignore
const selCollector = replyMsg.createMessageComponentCollector({ componentType: ComponentType.StringSelect, max: 1, time: 60000, filter: (sel: any) => sel.user.id === message.author.id });
selCollector.on('collect', async (sel: any) => { selCollector.on('collect', async (sel: any) => {
const idx = parseInt(sel.values[0]); const idx = parseInt(sel.values[0]);
const originalComponent = blockState.components[idx]; const originalComponent = blockState.components[idx];
@@ -470,9 +478,11 @@ export const command: CommandMessage = {
} }
const options = textDisplays.map(({ c, idx }: any) => ({ label: `Texto #${idx + 1}: ${c.content?.slice(0, 30) || '...'}`, value: String(idx), description: c.thumbnail ? 'Con thumbnail' : c.linkButton ? 'Con botón link' : 'Sin accesorio' })); const options = textDisplays.map(({ c, idx }: any) => ({ label: `Texto #${idx + 1}: ${c.content?.slice(0, 30) || '...'}`, value: String(idx), description: c.thumbnail ? 'Con thumbnail' : c.linkButton ? 'Con botón link' : 'Sin accesorio' }));
// @ts-ignore // @ts-ignore
const reply = await i.reply({ flags: 64, content: 'Elige el TextDisplay a editar su thumbnail:', components: [{ type: 1, components: [ { type: 3, custom_id: 'choose_text_for_thumbnail', placeholder: 'Selecciona un bloque de texto', options } ] }], fetchReply: true }); const reply = await i.reply({ flags: 64, content: 'Elige el TextDisplay a editar su thumbnail:', components: [{ type: 1, components: [ { type: 3, custom_id: 'choose_text_for_thumbnail', placeholder: 'Selecciona un bloque de texto', options } ] }] });
// @ts-ignore // @ts-ignore
const selCollector = reply.createMessageComponentCollector({ componentType: ComponentType.StringSelect, max: 1, time: 60000, filter: (it: any) => it.user.id === message.author.id }); const replyMsg = await i.fetchReply();
// @ts-ignore
const selCollector = replyMsg.createMessageComponentCollector({ componentType: ComponentType.StringSelect, max: 1, time: 60000, filter: (it: any) => it.user.id === message.author.id });
selCollector.on('collect', async (sel: any) => { selCollector.on('collect', async (sel: any) => {
const idx = parseInt(sel.values[0]); const idx = parseInt(sel.values[0]);
const textComp = blockState.components[idx]; const textComp = blockState.components[idx];
@@ -496,9 +506,11 @@ export const command: CommandMessage = {
} }
const options = textDisplays.map(({ c, idx }: any) => ({ label: `Texto #${idx + 1}: ${c.content?.slice(0, 30) || '...'}`, value: String(idx), description: c.linkButton ? 'Con botón link' : c.thumbnail ? 'Con thumbnail' : 'Sin accesorio' })); const options = textDisplays.map(({ c, idx }: any) => ({ label: `Texto #${idx + 1}: ${c.content?.slice(0, 30) || '...'}`, value: String(idx), description: c.linkButton ? 'Con botón link' : c.thumbnail ? 'Con thumbnail' : 'Sin accesorio' }));
// @ts-ignore // @ts-ignore
const reply = await i.reply({ flags: 64, content: 'Elige el TextDisplay donde agregar/editar el botón link:', components: [{ type: 1, components: [ { type: 3, custom_id: 'choose_text_for_linkbtn', placeholder: 'Selecciona un bloque de texto', options } ] }], fetchReply: true }); const reply = await i.reply({ flags: 64, content: 'Elige el TextDisplay donde agregar/editar el botón link:', components: [{ type: 1, components: [ { type: 3, custom_id: 'choose_text_for_linkbtn', placeholder: 'Selecciona un bloque de texto', options } ] }] });
// @ts-ignore // @ts-ignore
const selCollector = reply.createMessageComponentCollector({ componentType: ComponentType.StringSelect, max: 1, time: 60000, filter: (it: any) => it.user.id === message.author.id }); const replyMsg = await i.fetchReply();
// @ts-ignore
const selCollector = replyMsg.createMessageComponentCollector({ componentType: ComponentType.StringSelect, max: 1, time: 60000, filter: (it: any) => it.user.id === message.author.id });
selCollector.on('collect', async (sel: any) => { selCollector.on('collect', async (sel: any) => {
const idx = parseInt(sel.values[0]); const idx = parseInt(sel.values[0]);
const textComp = blockState.components[idx]; const textComp = blockState.components[idx];
@@ -511,7 +523,7 @@ export const command: CommandMessage = {
const sub = await i.followUp({ flags: 64, content: `Texto #${idx + 1}: ya tiene botón link. ¿Qué deseas hacer?`, components: [{ type: 1, components: [ const sub = await i.followUp({ flags: 64, content: `Texto #${idx + 1}: ya tiene botón link. ¿Qué deseas hacer?`, components: [{ type: 1, components: [
{ type: 2, style: ButtonStyle.Primary, label: '✏️ Editar', custom_id: `edit_link_button_modal_${idx}` }, { type: 2, style: ButtonStyle.Primary, label: '✏️ Editar', custom_id: `edit_link_button_modal_${idx}` },
{ type: 2, style: ButtonStyle.Danger, label: '🗑️ Eliminar', custom_id: `delete_link_button_${idx}` } { type: 2, style: ButtonStyle.Danger, label: '🗑️ Eliminar', custom_id: `delete_link_button_${idx}` }
] }], fetchReply: true }); ] }] });
// @ts-ignore // @ts-ignore
const btnCollector = sub.createMessageComponentCollector({ componentType: ComponentType.Button, max: 1, time: 60000, filter: (b: any) => b.user.id === message.author.id }); const btnCollector = sub.createMessageComponentCollector({ componentType: ComponentType.Button, max: 1, time: 60000, filter: (b: any) => b.user.id === message.author.id });
btnCollector.on('collect', async (b: any) => { btnCollector.on('collect', async (b: any) => {
@@ -547,7 +559,7 @@ export const command: CommandMessage = {
modal.addComponents(r1, r2, r3); modal.addComponents(r1, r2, r3);
await sel.update({ content: 'Abriendo modal…', components: [] }); await sel.update({ content: 'Abriendo modal…', components: [] });
// @ts-ignore // @ts-ignore
await i.showModal(modal); await sel.showModal(modal);
} }
}); });
break; break;