Added milliseconds to Duck result.
This commit is contained in:
parent
a46ffb431b
commit
9966c79a26
|
@ -59,12 +59,12 @@ function onCommand(args, context) {
|
||||||
const hit = Math.random() > config.duck.missRatio;
|
const hit = Math.random() > config.duck.missRatio;
|
||||||
const time = new Date().getTime() - duck.getTime();
|
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`
|
? `${(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)
|
.filter(([, value]) => value > 0)
|
||||||
.map(([key, value]) => `${value} ${key}`)
|
.map(([key, value]) => `${value} ${key}`)
|
||||||
.join(', ');
|
.join(', ')} and ${time % 1000} milliseconds`;
|
||||||
|
|
||||||
if (['bang', 'shoot'].includes(context.command)) {
|
if (['bang', 'shoot'].includes(context.command)) {
|
||||||
if (hit) {
|
if (hit) {
|
||||||
|
@ -81,6 +81,7 @@ function onCommand(args, context) {
|
||||||
`That's a miss! Better luck next time, ${context.user.prefixedUsername}.`,
|
`That's a miss! Better luck next time, ${context.user.prefixedUsername}.`,
|
||||||
`The duck outsmarted you, ${context.user.prefixedUsername}`,
|
`The duck outsmarted you, ${context.user.prefixedUsername}`,
|
||||||
`Channeling Gareth Southgate, ${context.user.prefixedUsername}? You missed!`,
|
`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());
|
shots.set(context.user.id, new Date());
|
||||||
|
|
Loading…
Reference in New Issue