Simp-O-Matic

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

commit e538169498c7a28c5a71982e91c653cbf5aa25cc
parent 177288fd79c46a48ce01fc254e7fc1a77cbea00d
Author: Daniel <23189912+danyisill@users.noreply.github.com>
Date:   Wed, 11 Nov 2020 13:21:25 +0300

Add raw output to youtube search.
Diffstat:
Mlib/commands/youtube.ts | 10++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/commands/youtube.ts b/lib/commands/youtube.ts @@ -6,12 +6,15 @@ import fetch from "node-fetch"; * !youtube x n, where 1 <= n <= 20 * !youtube new x * !youtube {channel,playlist} x + * !youtube raw x */ export default async (home_scope: HomeScope) => { const { message, args } = home_scope; let query = args.join(' ').trim(); - + + const rawOut = !!(args[0] == "raw" && args.shift()); + const sort_by = (args[0] == "new") ? (args.shift(), "upload_date") : "relevance"; @@ -44,7 +47,10 @@ export default async (home_scope: HomeScope) => { const views : string = Number(res.viewCount).to_abbrev(1); - message.answer(`Search for '${query}' (result №${num}):` + if(rawOut) + message.channel.send("https://youtu.be/" + res.videoId); + else + message.answer(`Search for '${query}' (result №${num}):` + ` https://youtu.be/${res.videoId}` + `\npublished ${res.publishedText},` + ` view count: ${views}, duration: ${duration}`);