You can use the setInterval()
method to do this. What this does is run a block of code every ___ seconds. Using this, and a variable to store a Unix timestamp of when the timer will finish, we can update a message using the .edit()
method, so it shows how much time is left.
bot.on("ready", () => {
// other code
const message = bot.guilds.cache.get('').channels.cache.get('').messages.fetch('');
let timeLeft = INSERT TIMESTAMP HERE;
setInterval(() => {
timeLeft -= 2000;
message.edit(`There is ${timeLeft} time left!`):
}, 2000)
})
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…