feat: improve editor interaction feedback and maintain active state during updates
This commit is contained in:
@@ -627,19 +627,32 @@ async function handleSaveBlock(
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleCancelBlock(interaction: ButtonInteraction, editorMessage: Message): Promise<void> {
|
async function handleCancelBlock(interaction: ButtonInteraction, editorMessage: Message): Promise<void> {
|
||||||
await interaction.update({
|
try {
|
||||||
content: "❌ **Editor cancelado**\n\nLa creación del bloque ha sido cancelada.",
|
await interaction.deferUpdate();
|
||||||
components: [],
|
} catch {}
|
||||||
embeds: []
|
await updateEditor(editorMessage, {
|
||||||
|
display: {
|
||||||
|
type: 17,
|
||||||
|
components: [
|
||||||
|
{ type: 10, content: "❌ **Editor cancelado**" },
|
||||||
|
{ type: 10, content: "La creación del bloque ha sido cancelada." }
|
||||||
|
]
|
||||||
|
} as any,
|
||||||
|
components: []
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleEditorTimeout(editorMessage: Message): Promise<void> {
|
async function handleEditorTimeout(editorMessage: Message): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await editorMessage.edit({
|
await updateEditor(editorMessage, {
|
||||||
content: "⏰ **Editor expirado**\n\nEl editor ha expirado por inactividad. Usa el comando nuevamente para crear un bloque.",
|
display: {
|
||||||
components: [],
|
type: 17,
|
||||||
embeds: []
|
components: [
|
||||||
|
{ type: 10, content: "⏰ **Editor expirado**" },
|
||||||
|
{ type: 10, content: "El editor ha expirado por inactividad. Usa el comando nuevamente para crear un bloque." }
|
||||||
|
]
|
||||||
|
} as any,
|
||||||
|
components: []
|
||||||
});
|
});
|
||||||
} catch {
|
} catch {
|
||||||
// message likely deleted
|
// message likely deleted
|
||||||
|
|||||||
@@ -202,19 +202,18 @@ export const command: CommandMessage = {
|
|||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
data: { config: blockState }
|
data: { config: blockState }
|
||||||
});
|
});
|
||||||
|
// Mantener el editor activo y los botones funcionando
|
||||||
await updateEditor(editorMessage, {
|
await updateEditor(editorMessage, {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
display: {
|
display: await renderPreview(blockState, message.member, message.guild),
|
||||||
type: 17,
|
components: btns(false)
|
||||||
accent_color: blockState.color ?? null,
|
|
||||||
components: [
|
|
||||||
{ type: 10, content: `✅ Actualizado: ${blockName}` },
|
|
||||||
{ type: 10, content: "Cambios guardados en la base de datos." }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
components: []
|
|
||||||
});
|
});
|
||||||
collector.stop();
|
// Confirmación efímera
|
||||||
|
try {
|
||||||
|
// @ts-ignore
|
||||||
|
await i.followUp({ flags: 64, content: `✅ Cambios de "${blockName}" guardados.` });
|
||||||
|
} catch {}
|
||||||
|
// No detener el collector para permitir mover/eliminar después de guardar
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case "cancel_block": {
|
case "cancel_block": {
|
||||||
|
|||||||
Reference in New Issue
Block a user