首页 > 解决方案 > 我想在排行榜中标记用户,但它标记了他们的 id

问题描述

我正在尝试为我的不和谐机器人制作排行榜,到目前为止它可以工作,但是每当我想在嵌入中标记玩家时,它只会发送类似 <@90258560912791> 的内容,而不是:@wex

这是我的代码:

if (message.content.startsWith(`${prefix}btop`)) {
  if (message.member.roles.cache.find(r => r.name === "Walls")) {
    var description = ""
    let all = `SELECT userid , points FROM bufferpoints ORDER BY points DESC LIMIT 10;`
    db.all(all, (err, row) => {
      if (err) throw err;
      const topembed = new Discord.MessageEmbed()
        .setColor('#FF760B')
        .setTitle(message.guild.name + "'s TOP Buffercheckers!")
        .setTimestamp()
      let i = 0;
      row.forEach(function(row) {
        i++;
        if (row.points === 0) {
          return;
        }
        description += ` ${i}. <@${row.userid}>` + `** - ${row.points}**\n`
      })

      topembed.setDescription(description)
      message.channel.send(topembed)
    })
  }
}

如果有人想知道,这就是我现在得到的

1]

谢谢你的帮助!

标签: javascriptdiscordleaderboard

解决方案


我设法解决了这个问题。当我保存用户 ID 时,我使用了message.author.id. 我把它改成了message.author.toString(). Bot 将数据保存为 <@125512>,然后在排行榜中标记用户。


推荐阅读