rate command with discord.js v12



我想知道如何使费率稳定,这样当我标记某人或自己标记时,数字就不会每次都改变。

client.on('message', message =>{
if(message.content.toLowerCase().startsWith(prefix + "rate")) {
let args = message.content.slice(prefix.length).split(/ +/);
const newEmbed = new Discord.MessageEmbed()
.setColor('#B99DF0')
let number = Math.floor(Math.random() * 101);
if (!args[1]){
newEmbed.setDescription(`**${message.author.tag} I would rate you a `+number+`/100**`)
} else {
let user = message.mentions.users.first();
if (!user){
return newEmbed.setDescription('please include who you are rating.')
}
newEmbed.setDescription(`**${message.author.tag} I would rate `+user.username+` a `+number+`/100**`)
}
message.channel.send(newEmbed)
}
})

假设你谈论的是让特定用户的评级保持不变,你需要使用某种数据库,否则你将无法做到这一点。

一个好的数据库应该是MongoDB。如果这对你不起作用,可以在discord.js教程中试试这篇文章。

花点时间学习数据库的基本知识,不要因为命令的简单性而急于学习。当你熟悉数据库后,你就会确切地知道如何做到

最新更新