繁体   English   中英

使用 discord.js v12 的速率命令

[英]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 教程上的这篇文章

花点时间学习数据库的基础知识,不要为了命令的简单而急于求成。 熟悉数据库后,您将确切知道如何操作

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM