【发布时间】:2020-06-27 05:50:34
【问题描述】:
我希望显示冷却时间的剩余时间,但我不确定是否可以使用我目前拥有的格式来完成。可能吗?或者有没有更好的方法来使用冷却时间?我删掉了大部分与此相关的代码,因为它不相关。
let cooldown = new Set();
if(msgObject.content.startsWith("-eat")) {
let amount = Math.floor(Math.random() * 2500) + 1;
let Channel = msgObject.channel.id
if(Channel != `623195917083738136` && Channel != `623195981919289344` ){//bot test
msgObject.channel.send('Cannot use command here, ' + msgObject.author)
.then(msg => {
(msg as Discord.Message).delete(20000)
.catch(console.error);
})
return;
}
if(cooldown.has(msgObject.author.id)){
msgObject.channel.send(`You have to wait 3 hours to use this command again!`)
.then(msg => {
(msg as Discord.Message).delete(20000)
.catch(console.error);
})
return;
}
if(msgObject.content.startsWith("-eat")){
cooldown.add(msgObject.author.id)
}
setTimeout(() => {
cooldown.delete(msgObject.author.id)
}, cdseconds * 1000);
{let embed = new Discord.RichEmbed()
.setAuthor(`${msgObject.author.tag}`, msgObject.author.displayAvatarURL)
.setDescription(`${msgObject.author}, ${(eat[index1])}${amount} DinoBucks`)
.setColor("RANDOM");
msgObject.channel.send(embed)
.then(msg => {
(msg as Discord.Message).delete(20000)
.catch(console.error);
})
}
}
}
【问题讨论】:
标签: javascript typescript discord discord.js