javascript - 我想在排行榜中标记用户,但它标记了他们的 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)
})
}
}
如果有人想知道,这就是我现在得到的
谢谢你的帮助!
解决方案
我设法解决了这个问题。当我保存用户 ID 时,我使用了message.author.id
. 我把它改成了message.author.toString()
. Bot 将数据保存为 <@125512>,然后在排行榜中标记用户。
推荐阅读
- php - Apache 中的多个 Laravel 站点与 Apache 服务器上的 MSSql 和 Redis 冲突
- java - Selenium 如何从弹出通知中获取文本
- stored-procedures - 推断存储在 cassandra 列中每行的 JSON 文件的字节大小
- java - 在 java 中使用 hasrsine 公式或一些高级 postgis 查询?
- drools - Drools 7.39.0 是否支持 jBoss EAP
- python - 尝试使用 any() 更改 url 中的单词
- python - 如何使用python将列中的列表拆分为数据框中的两列?
- java - 如何将大型 POJO 响应从 Spring Boot 发送到客户端
- python - 如何将部分列列表转换为日期时间
- c - 在代码文件上定义函数但不在标题上声明它是一种好习惯吗?