Skip to content

Instantly share code, notes, and snippets.

@brian6932
Last active January 24, 2024 13:42
Show Gist options
  • Save brian6932/7d7a15d093b1fcecaea18327ccf02076 to your computer and use it in GitHub Desktop.
Save brian6932/7d7a15d093b1fcecaea18327ccf02076 to your computer and use it in GitHub Desktop.
const
y = 31_536_000,
d = 86_400,
h = 3_600,
m = 60,
secondsConverter = function (input) {
let remainder
this.y = input / y | 0
this.d = (remainder = input - y * this.y) / d | 0
this.h = (remainder -= d * this.d) / h | 0
this.m = (remainder -= h * this.h) / m | 0
},
secondsFmt = input => {
input = new secondsConverter(input)
let
i = 0,
out = ``
for (const field in input) {
if (!input[field])
continue
out += (out.length ? `, ` : ``) + input[field] + field
if (++i === 2)
break
}
return out
},
execute = async function () {
const cmd = await command.execute(...arguments)
if (!cmd.success) {
let acc = ``
for (const argument of arguments)
acc += argument + ` `
throw Error(`$${acc}\u{2022} ${cmd.reason ?? cmd.reply}`)
}
return cmd.reply
},
main = async () => `(${secondsFmt(1.893e8 * Math.random() + 1)} ago) ${args[0]?.slice(args[0][0] === `@`) || await execute(`abb`, `chatter`, `excludeSelf:true`)}: ${await execute(`fakenews`)}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment