I have been making a Discord.JS bot and I have an issue with my !userinfo command. There are quite a few issues I am facing but all of them because I don't know how to handle Promises in DiscordJS correctly. No site has been helping me. I have included comments under the lines giving me issues.
const memberemb = message.guild.members.fetch(user);
Promise.resolve(memberemb).then(function () {
console.log(memberemb.roles);
const embed = new Discord.MessageEmbed()
.setColor("RANDOM")
.setThumbnail(message.author.avatarURL)
.addField(`${user.tag}`, `${user}`, true)
.addField("ID:", `${user.id}`, true)
.addField("Nickname:", `${useralso.nickname ? `${useralso.nickname}` : 'None'}`, true)
.addField("Status:", `${user.presence.status}`, true)
// always shows offline in status
.addField("Game:", `${user.presence.game ? user.presence.game.name : 'None'}`, true)
//idk if it shows games correctly
.addField("Joined The Server On:", `${moment.utc(memberemb.joinedAt).format("dddd, MMMM Do YYYY")}`, true)
//shows date of today not of the joined on date
.addField("Account Created On:", `${moment.utc(user.createdAt).format("dddd, MMMM Do YYYY")}`, true)
.addField("Roles:", memberemb.roles ? memberemb.roles.map(roles => `${roles}`).join(', ') : "None", true)
//shows none as roles
.setFooter(`Replying to ${message.author.username}#${message.author.discriminator}`)
message.channel.send({ embed });
});
break;
Please explain how to fix this and also rewrite the code correctly(please) so I can use it for my bot
Thank you