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

208
Views
Cómo borrar datos anteriores de Discord.MessageEmbed en Discord.js

Estoy tratando de hacer un comando de francotirador para el bot de CC, pero no puedo hacer que la inserción se reinicie. Intenté poner incrustar = {} en diferentes ubicaciones, luego intenta enviar un mensaje vacío la próxima vez y sale un error. También se dejó incrustar ahora ya que estaba probando, probé const primero. Editar: ahora funciona cuando se revisan los mensajes en otro lugar, debería haberlo hecho para empezar. Código:

 bot.on('messageDelete', message => { let embed = new Discord.MessageEmbed() .setAuthor(`${message.author.username} (${message.author.id})`, message.author.avatarURL()) .setDescription(message.content || "None") bot.on('message', message => { const args = message.content.slice(PREFIX.length).split(/ +/); const cmd = args.shift().toLowerCase(); if (cmd === 'msg'){ message.channel.send(embed) } }) })
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

No necesita un embed = {} , en su lugar use client.snipes = new Map() como colector. Entonces, si alguien elimina el mensaje cuando el bot está en línea, el bot puede detectarlo.

 client.snipes = new Map() client.on('messageDelete', function(message, channel) { client.snipes.set(message.channel.id, { content: message.content, author: message.author, image: message.attachments.first() ? message.attachments.first().proxyURL : null }) }) //This will be your collector on your index file.

A continuación, cree un archivo de comandos.

 const msg = client.snipes.get(message.channel.id) if(!msg) return message.channel.send("Didn't find any deleted messages.") const embed = new MessageEmbed() .setDescription(`Your_Message`) .setTimestamp() if(msg.image) embed.setImage(msg.image) //If image deleted, it will go here. message.channel.send({ embeds: [embed] })
about 4 years ago · Juan Pablo Isaza Report

0

Cada vez que se elimina un mensaje, se vuelve a suscribir al evento del mensaje. Sugeriría llevar algo de esa lógica fuera de ese ámbito.

 let embed = null; bot.on('messageDelete', message => { embed = new Discord.MessageEmbed() .setAuthor(`${message.author.username} (${message.author.id})`, message.author.avatarURL()) .setDescription(message.content || "None") }) bot.on('message', message => { const args = message.content.slice(PREFIX.length).split(/ +/); const cmd = args.shift().toLowerCase(); if (cmd === 'msg' && embed){ message.channel.send(embed) } })
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!