embed table whit top 3 members and change their nicknames
hi, i have a embed table whit top 3 members, i dont find the way of how i can change their nicknames adding a crown emoji at the end
4 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by OPconst {SlashCommandBuilder, GuildMember} = require("discord.js");
const {EmbedBuilder} = require("@discordjs/builders")
const profileModel = require("../models/profileSchema")
module.exports = {
data: new SlashCommandBuilder()
.setName("leaderboard")
.setDescription("Top 3"),
async execute(interaction, profileData){
await interaction.deferReply();
let leaderboardEmbed = new EmbedBuilder() .setTitle("Top 3 members") .setColor(0xEFFF00) const members = await profileModel .find() .sort({actividad: -1}) .catch((err)=>console.log(err))
const topTres = members.slice(0, 3); let desc = ""; for(let i = 0; i<topTres.length; i++){ let {user} = await interaction.guild.members.fetch(topTres[i].userId); if(!user)return; let userBalance = topTres[i].actividad; let crownEmoji = "👑"; desc +=
let leaderboardEmbed = new EmbedBuilder() .setTitle("Top 3 members") .setColor(0xEFFF00) const members = await profileModel .find() .sort({actividad: -1}) .catch((err)=>console.log(err))
const topTres = members.slice(0, 3); let desc = ""; for(let i = 0; i<topTres.length; i++){ let {user} = await interaction.guild.members.fetch(topTres[i].userId); if(!user)return; let userBalance = topTres[i].actividad; let crownEmoji = "👑"; desc +=
**${crownEmoji} ${user.username}:** ${userBalance} Messages\n
;
}
if(desc !== ""){
leaderboardEmbed.setDescription(desc);
}
await interaction.editReply({embeds: [leaderboardEmbed]})
}
}
this is my code
change the name in the guildso, inside the for(let...) i have to add members.setNickname(…) ?
i added
const guild = interaction.guild;
const member = await guild.members.fetch(topTres[i].userId);
member.setNickname(
${user.username}👑
)
and solved, ty fella