This commit is contained in:
Sarimoko 2022-02-14 03:38:50 -08:00
parent e7f35a27be
commit 4bc44f17e7
1 changed files with 13 additions and 14 deletions

View File

@ -20,15 +20,15 @@ export function rnguser() {
}) })
} }
function getRandomChatter(channelName, opts = {}) { function getRandomChatter(channelName, opts = {}) {
let { let {
onlyViewers = false, onlyViewers = false,
noBroadcaster = false, noBroadcaster = false,
skipList = [] skipList = []
} = opts; } = opts;
return getChatters(channelName) return getChatters(channelName)
.then(data => { .then(data => {
let chatters = data let chatters = data
.filter(({ name, type }) => .filter(({ name, type }) =>
!( !(
(onlyViewers && type !== 'viewers') || (onlyViewers && type !== 'viewers') ||
@ -36,10 +36,9 @@ function getRandomChatter(channelName, opts = {}) {
skipList.includes(name) skipList.includes(name)
) )
); );
return chatters.length === 0 ? return chatters.length === 0 ?
null : null :
chatters[Math.floor(Math.random() * chatters.length)]; chatters[Math.floor(Math.random() * chatters.length)];
}); });
} // RNG END }
}
}