【问题标题】:rate command with discord.js v12使用 discord.js v12 的 rate 命令
【发布时间】:2020-12-16 06:52:19
【问题描述】:

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

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)
  }
})

【问题讨论】:

  • 有人让我在数据库中创建它,但我不知道该怎么做。

标签: javascript discord discord.js


【解决方案1】:

假设您要让特定用户的评分保持不变,您将需要使用某种数据库,否则您将无法这样做。

一个好的数据库是MongoDB。如果这不适合您,请尝试out this article on the discord.js tutorial

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

【讨论】:

    猜你喜欢
    • 2021-01-01
    • 2021-02-18
    • 1970-01-01
    • 2021-03-26
    • 2021-01-18
    • 2021-04-14
    • 2021-04-19
    • 2021-04-18
    • 2021-04-23
    相关资源
    最近更新 更多