【问题标题】:what is the time unit used in intervals in discord.js?discord.js中间隔使用的时间单位是什么?
【发布时间】:2021-06-02 17:47:57
【问题描述】:

我正在编写一些代码,我希望它在执行间隔时检测用户是否在 2 个月内创建,我用谷歌搜索了 2 个月的毫秒数(5259600000),我得到了间隔工作在毫 idk 中从那里得到的,但代码并没有真正说它的 2 个月,我有一个 6-7 天的 alt,仍然检测为 alt,但是当我将间隔增加到 5259492000000 时,它检测到 2020 年的 accs 作为 alt ,所以我只需要在间隔中使用的时间帮助,这真的让我很困惑。

如果有帮助,代码如下:

bot.on('guildMemberAdd', async member => {
    if (member.user.createdAt < 5259492000000) {
        const cachedInvites = guildInvites.get(member.guild.id);
        const newInvites = await member.guild.fetchInvites();
        guildInvites.set(member.guild.id, newInvites);
        let Muterole = member.guild.roles.cache.find(role => role.id == "847963874278768650")
        member.roles.add(Muterole)
        const usedInvite = newInvites.find(inv => cachedInvites.get(inv.code).uses < inv.uses);
        const embed = new MessageEmbed()
            .setDescription(`${member.user} is an **ALT**\n created at\n${member.user.createdAt}\n Inv Code: ${usedInvite.url} \nInv Code Owner ${usedInvite.inviter.tag},||this might not be the real owner of the invite.||`) //${member.user}** is created at**\n${member.user.createdAt}\n Inv Code: ${usedInvite.url} \nInv Code Owner ${usedInvite.inviter.tag},||this might not be the real owner of the invite.||
            .setTimestamp()
        const logchannel = member.guild.channels.cache.find(channel => channel.id === '847510771670974555');
        if (logchannel) {
            logchannel.send(embed).catch(err => console.log(err));
        }
    }
});

【问题讨论】:

  • Surely createdAt 是一个时间戳,而不是时间间隔 - 它是创建帐户的时间,而不是多久之前。
  • 是的对不起我的错,我的意思是,如果 acc 是在 2 个月内创建的,比如帐户年龄小于 xxxxxxxxxxxxx 毫秒,你明白我的意思,对吗? @jonrsharpe

标签: discord.js


【解决方案1】:
 if (Date.now() - member.user.createdAt < 5259600000 ) {
    // code here
  }

【讨论】:

  • 如果代码有效,我会很高兴,感谢您的回复:)
猜你喜欢
  • 2022-01-22
  • 1970-01-01
  • 2012-06-11
  • 1970-01-01
  • 1970-01-01
  • 2021-08-09
  • 1970-01-01
  • 1970-01-01
  • 2011-10-11
相关资源
最近更新 更多