From 4bc44f17e785b5d6b6217715236e67c9b31fdcd3 Mon Sep 17 00:00:00 2001 From: Sarimoko Date: Mon, 14 Feb 2022 03:38:50 -0800 Subject: [PATCH] more --- node/rng.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/node/rng.js b/node/rng.js index 5203646..4640904 100644 --- a/node/rng.js +++ b/node/rng.js @@ -20,15 +20,15 @@ export function rnguser() { }) } -function getRandomChatter(channelName, opts = {}) { - let { - onlyViewers = false, - noBroadcaster = false, - skipList = [] - } = opts; - return getChatters(channelName) - .then(data => { - let chatters = data + function getRandomChatter(channelName, opts = {}) { + let { + onlyViewers = false, + noBroadcaster = false, + skipList = [] + } = opts; + return getChatters(channelName) + .then(data => { + let chatters = data .filter(({ name, type }) => !( (onlyViewers && type !== 'viewers') || @@ -36,10 +36,9 @@ function getRandomChatter(channelName, opts = {}) { skipList.includes(name) ) ); - return chatters.length === 0 ? + return chatters.length === 0 ? null : chatters[Math.floor(Math.random() * chatters.length)]; - }); -} // RNG END - - } \ No newline at end of file + }); + } +} \ No newline at end of file