in Education by
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)

1 Answer

0 votes
by
I hope I understood your question well. Just define different RichEmbeds in different variables. I defined embed1 and embed2. embed1 you use for your myavatar command and embed2 for your avatar command, so these 2 RichEmbeds are 2 different embeds with different values. Here is the code how you can do it for your avatar and myavatar command: const Discord = require('discord.js'); client.on('message', message => { const authorID = message.author.id; const authorAvatarLink = message.author.avatarURL; const embed1 = new Discord.RichEmbed() const embed2 = new Discord.RichEmbed() if (message.content.toLowerCase() === commandPrefix + 'myavatar') { embed1.setAuthor(message.author.username, message.author.avatarURL); embed1.setDescription(authorAvatarLink); embed1.setImage(authorAvatarLink); message.channel.send({embed : embed1}); } 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) { embed2.setAuthor(user.username, user.avatarURL); embed2.setDescription(user.avatarURL); embed2.setImage(user.avatarURL); embed2.setFooter('Requested by ' + message.author.tag); message.reply({ embed: embed2 }); } else { var errorCmd = (commandPrefix + 'avatar'); commandError(message, userMention(authorID), errorCmd, msgContent); } user = undefined; delete(user); embed2.setImage(null); } });

Related questions

0 votes
    I've been trying to get my discord bot to work, but it will only become online on discord and ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I would like to document in the shaded jar what maven artifacts actually end up in that shaded jar. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 5, 2022 in Education by JackTerrance
0 votes
    I need to know how to use the delete_channel command in discord.py may someone please post a code sample ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 12, 2022 in Education by JackTerrance
0 votes
    I need to know how to use the delete_channel command in discord.py may someone please post a code sample ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 10, 2022 in Education by JackTerrance
0 votes
    A ________________ tool permits security professional or a hacker to embed hidden data within a carrier file ... Cyber Security:,Cyber Security-Jobs:,Cyber Security Applications...
asked Oct 31, 2021 in Education by JackTerrance
0 votes
    Can anyone tell me how do I become a react JS developer from scratch? Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I need to find a message the bot has previously posted, then see the reactions on it. I don't ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    How can discord be dealt with within the Scrum Team?...
asked Nov 19, 2020 in Technology by Editorial Staff
0 votes
    What does the command git reset –hard HEAD ~3 do? A. Merges the last 3 commits to the master B. Discards ... nothing D. Resets the head to 3 commits before the current commit...
asked Dec 23, 2022 in Technology by JackTerrance
0 votes
    Apologies if this question is answered elsewhere on StackOverflow, I did my best to search for an answer ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    I have some trouble to correctly embed images in html/php email. My .php file just sends out a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I have some trouble to correctly embed images in html/php email. My .php file just sends out a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    How can you embed a Visualflow in a Visualforce page?...
asked Nov 11, 2020 in Technology by JackTerrance
0 votes
    Hi I'm having some issues showing lists in my embed correctly. I'm trying to get my roles to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    App needs to run on the .Net Compact Framework v.3.5. Video can be any format, but I do need ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
...