Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

185
Visualizações
How to detect if a message is not blank

I've been trying to create a modmail system where you can send images to the support team, but I get MessageEmbed field value may not be blank (this is for the Embed where the message is). How can I detect if there is or is not any text to go along with their image?

This is my code

const Embed = new Discord.MessageEmbed()
            .setAuthor("Message from recipient", message.author.displayAvatarURL())
            .setDescription(`A message has been recieved from ${message.author.tag}`)
          if (message.attachments.size < 0) {
            Embed.addField("Message:", message.content)
          } else {
            if (message.attachments.every(attachIsImage)) {
              
              Embed.setImage(message.attachments.first())
            }
          }

          function attachIsImage(msgAttach) {
            var url = msgAttach.url;
            //True if this url is a png image.
            return url.indexOf("png", url.length - "png".length /*or 3*/) !== -1;
          }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Assuming the rest of the code works as expected just change this line

Embed.addField("Message:", message.content || 'No message')
// this adds a message if none is present
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda