簡體   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