Simp-O-Matic

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

commit db328516b2fd5b886dc9f02fc7e59b0ce08846f5
parent 58e9fb4b563f965b48390b19e6d3fb1c86bbbdee
Author: Demonstrandum <moi@knutsen.co>
Date:   Wed, 11 Nov 2020 03:33:51 +0000

Treat media list as queue.

Diffstat:
Mlib/commands/vc.ts | 12+++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/lib/commands/vc.ts b/lib/commands/vc.ts @@ -62,7 +62,7 @@ export default async(home_scope: HomeScope) => { } break; } case "play": { - if (GID.vc_dispatcher) { + if (GID.vc_dispatcher.paused) { GID.vc_dispatcher.resume(); message.answer("Resuming playback."); } else { @@ -71,14 +71,20 @@ export default async(home_scope: HomeScope) => { return; } - const stream = GID.vc_prefetch[CONFIG.vc_queue.pop()]; + const stream = GID.vc_prefetch[CONFIG.vc_queue.shift()]; GID.vc_current_stream = stream; GID.vc_dispatcher = GID.vc.play(stream); message.channel.send("Playing media from queue..."); const end_handler = () => { GID.vc_dispatcher.destroy(); - const next = CONFIG.vc_queue.pop(); + if (CONFIG.vc_queue.length === 0) { + CLIENT.channels.fetch(CONFIG.vc_channel) + .then((ch: TextChannel) => + ch.send("Media queue ended.")); + return; + } + const next = CONFIG.vc_queue.shift(); if (next) { const stream = GID.vc_prefetch[next]; GID.vc_current_stream = stream;