Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

257
Views
DiscordJS, elimine el mensaje incrustado anterior después de recibir el comando de barra

Tengo un bot que envía un mensaje incrustado después de recibir un /xyz con algo como esto

 client.on("interactionCreate", async (interaction) => { if (!interaction.isCommand()) return; const { commandName } = interaction; if (commandName === "xyz") { const embed = { title: "title of embed message", description: "description of embed message", .... } await interaction.channel.send({ embeds: [embed] }); }

Me gustaría saber cómo eliminar los mensajes incrustados anteriores que envió el bot, antes de enviar uno nuevo después de recibir el comando /xyz

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Establezca una variable en el ámbito externo que asignará al enviar las incrustaciones. Eliminarlo cada vez que se ejecuta el comando

 let embedBefore; client.on("interactionCreate", async (interaction) => { if (!interaction.isCommand()) return; const { commandName } = interaction; if (commandName === "xyz") { await embedBefore?.delete().catch(console.error) // delete the embed, catch and log error if thrown const embed = { title: "title of embed message", description: "description of embed message" } // assign embedBefore to the sent embed; Note: this is not an interaction reply embedBefore = await interaction.channel.send({ embeds: [embed] }); } })

La inserción permanecerá allí cuando se reinicie el bot y se vuelva a ejecutar el comando.

about 4 years ago · Juan Pablo Isaza Report

0

Puede almacenar las incrustaciones anteriores (solo debe haber una, cierto, ya que elimina las anteriores ...) en algo así como un Set si tiene varias incrustaciones de alguna manera y luego, antes de enviar su respuesta, itere sobre el Conjunto e invoque el método delete() en los mensajes almacenados. Aquí la documentación para Sets en caso de que necesite más información.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!