I'm using const embed = new Discord.RichEmbed(); for my embeds. How do I reset the Embed values?
After I run a command that sets the embed elements, it carries over to the next command. How can I make it so the values don't carry over and I wont get this result?
My code for the myavatar and avatar commands.
client.on('message', message => {
const authorID = message.author.id;
const authorAvatarLink = message.author.avatarURL;
if (message.content.toLowerCase() === commandPrefix + 'myavatar') {
embed.setAuthor(message.author.username, message.author.avatarURL);
embed.setDescription(authorAvatarLink);
embed.setImage(authorAvatarLink);
message.channel.send(embed);
}
if (message.content.toLowerCase().startsWith(commandPrefix + 'avatar')) {
var user = message.mentions.users.first();
var msgContent = message.content.substr(7, (message.content.length));
if (user != null) {
embed.setAuthor(user.username, user.avatarURL);
embed.setDescription(user.avatarURL);
embed.setImage(user.avatarURL);
embed.setFooter('Requested by ' + message.author.tag);
message.channel.send(userMention(authorID), embed);
} else {
var errorCmd = (commandPrefix + 'avatar');
commandError(message, userMention(authorID), errorCmd, msgContent);
}
user = undefined;
delete(user);
embed.setImage(null);
}
});
My code for the membercount command.
client.on('message', message => {
if (message.content.toLowerCase() === commandPrefix + 'membercount') {
var memberCount = message.guild.memberCount;
embed.setColor(nvdMainColor);
embed.setAuthor(message.author.username, message.author.avatarURL);
embed.setTimestamp(new Date());
embed.addField('Total Members', memberCount);
message.channel.send(embed);
}
});
What can I do to prevent the values from carrying over into other commands?
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)