【问题标题】:Time limit with the "ms" package“ms”包的时间限制
【发布时间】:2020-09-18 17:17:55
【问题描述】:
let giveawayDuration = response2.first();

// Limit duration to max 15d
            if (giveawayDuration > ms('15d')) {
                const l1 = new Discord.MessageEmbed()
                .setColor('#ff0000')
                .setDescription(❌ Your duration cannot be more than 15 Days!)
                return message.channel.send(l1);
            }

它为什么会阻止每个持续时间,有人知道为什么/我做错了什么?

const ms = require('ms');

const response2 = await message.channel.awaitMessages(m => m.author.id === message.author.id, { max: 1 });

【问题讨论】:

  • 您需要显示ms() 函数的定义以及response2 是什么。
  • 编辑它,ms是一个非常非常流行的包它只是为了你不必写129000000
  • 但我编辑了它
  • response2.first() 真的返回一个数字吗?
  • 所以giveawayDuration 是“10d”而ms('15d') 是129000000,所以你的比较是"10d" > 129000000?

标签: javascript time bots discord discord.js


【解决方案1】:

解决办法是:"ms(giveawayDuration.content) > ms('15d')"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多