'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;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
