Alfie3008
Alfie3008

Reputation: 35

Discord.js Timer Command

I was just wondering how I can make a simple countdown command using ms, so that when someone types !timer (time) (s/m/h) it starts a timer for the requested amount of time, and once the countdown is over sends a message

Upvotes: 0

Views: 1213

Answers (1)

user13429955
user13429955

Reputation:

Assuming you already know how to get the args variable and validate the command:

//msg = <Message>
//client = <Client>

const time = ms(args[0]);
if(!time) return msg.channel.send("invalid time");

client.setTimeout(() => msg.channel.send("time up"), time);

Upvotes: 2

Related Questions