Added milliseconds to Duck result.

This commit is contained in:
ThePendulum 2023-07-18 23:35:53 +02:00
parent a46ffb431b
commit 9966c79a26
1 changed files with 4 additions and 3 deletions

View File

@ -59,12 +59,12 @@ function onCommand(args, context) {
const hit = Math.random() > config.duck.missRatio;
const time = new Date().getTime() - duck.getTime();
const distance = time < 600 * 1000 // show exact time up to ten minutes
const distance = time < 60 * 1000 // show digits up to one minute
? `${(time / 1000).toFixed(3)} seconds`
: Object.entries(intervalToDuration({ start: duck, end: new Date() }))
: `${Object.entries(intervalToDuration({ start: duck, end: new Date() }))
.filter(([, value]) => value > 0)
.map(([key, value]) => `${value} ${key}`)
.join(', ');
.join(', ')} and ${time % 1000} milliseconds`;
if (['bang', 'shoot'].includes(context.command)) {
if (hit) {
@ -81,6 +81,7 @@ function onCommand(args, context) {
`That's a miss! Better luck next time, ${context.user.prefixedUsername}.`,
`The duck outsmarted you, ${context.user.prefixedUsername}`,
`Channeling Gareth Southgate, ${context.user.prefixedUsername}? You missed!`,
`Oh, and that's a bad miss, ${context.user.prefixedUsername}.`,
]);
shots.set(context.user.id, new Date());