Simp-O-Matic

Dumb Discord bot in TS.
git clone git://git.knutsen.co/Simp-O-Matic
Log | Files | Refs | README | LICENSE

commit 11889493d748483ff11b283ef9f523259aa87c2d
parent a2e8a7efa610da1611a771a233211ab849278f7e
Author: Demonstrandum <moi@knutsen.co>
Date:   Mon,  6 Jul 2020 17:28:29 +0100

Format numbers nicely in !youtube command.

Diffstat:
Mlib/commands/youtube.ts | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/commands/youtube.ts b/lib/commands/youtube.ts @@ -24,8 +24,12 @@ export default async (home_scope: HomeScope) => { const result = await fetch(`https://invidio.us/api/v1/search?q=${query}&sort_by=${sort_by}&type=${type}`); const res_json = await result.json(); const res = res_json[Math.abs(num - 1)]; - message.answer(`Search for '${query}' (result №${num}): https://youtu.be/${res.videoId} \n published ${res.publishedText} view count: ${res.viewCount} length: ${res.lengthSeconds / 60} minutes`); - //todo timestamp generation + const duration = new Date(res.lengthSeconds * 1000) + .toISOString() + .substr(11, 8); + const views = Number(res.viewCount).to_abbrev(2); + message.answer(`Search for '${query}' (result №${num}): https://youtu.be/${res.videoId} \n published ${res.publishedText} view count: ${views} duration: ${duration}`); + // TODO timestamp generation /*yt_search({ query }) .then(message.reply.bind(message))