我想在排行榜中标记用户,但它标记其ID

问题描述 投票:0回答:1

我正在尝试为我的discord机器人制作排行榜,到目前为止,它仍然可以正常工作,但是只要我想在嵌入中标记玩家,它只会发送类似这样的内容而不是:@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)
    })
  }
}

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

“

感谢您的帮助!

javascript discord leaderboard
1个回答
0
投票

我设法解决了这个问题。保存用户ID时,我使用了message.author.id。我将其更改为message.author.toString()。 Bot将数据另存为,然后在排行榜中为用户添加标签。

© www.soinside.com 2019 - 2024. All rights reserved.