From a719ccecd9fb6a0542b40502e9ce1b788f413cf5 Mon Sep 17 00:00:00 2001 From: KGT1 Date: Wed, 23 Sep 2020 17:42:13 +0200 Subject: [PATCH] fix lint --- src/messagehandler.js | 7 +++---- src/playbackmanager.js | 2 +- src/util.js | 16 ++++++++-------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/messagehandler.js b/src/messagehandler.js index a4dee72..7fc0d83 100644 --- a/src/messagehandler.js +++ b/src/messagehandler.js @@ -44,7 +44,7 @@ function getRandomDiscordColor () { return ("#" + ("00" + (randomNumber(rS, rE)).toString(16)).substr(-2) + ("00" + (randomNumber(gS, gE)).toString(16)).substr(-2) + ("00" + (randomNumber(bS, bE)).toString(16)).substr(-2)); } -function getDiscordEmbedError(e){ +function getDiscordEmbedError (e) { return new Discord.MessageEmbed() .setColor(0xff0000) .setTitle("Error!") @@ -52,7 +52,6 @@ function getDiscordEmbedError(e){ .setDescription("<:x:757935515445231651> " + e); } - // Song Search, return the song itemID async function searchForItemID (searchString) { const response = await jellyfinClientManager.getJellyfinClient().getSearchHints({ @@ -114,7 +113,7 @@ async function playThis (message) { } catch (e) { const noSong = getDiscordEmbedError(e); message.channel.send(noSong); - playbackmanager.stop(isSummendByPlay?discordClient.user.client.voice.connections.first():undefined); + playbackmanager.stop(isSummendByPlay ? discordClient.user.client.voice.connections.first() : undefined); return; } } @@ -182,7 +181,7 @@ function handleChannelMessage (message) { const indexOfArgument = message.content.indexOf(CONFIG["discord-prefix"] + "seek") + (CONFIG["discord-prefix"] + "seek").length + 1; const argument = message.content.slice(indexOfArgument); try { - playbackmanager.seek(hmsToSeconds(argument)*10000000); + playbackmanager.seek(hmsToSeconds(argument) * 10000000); } catch (error) { const errorMessage = getDiscordEmbedError(error); message.channel.send(errorMessage); diff --git a/src/playbackmanager.js b/src/playbackmanager.js index 06694d5..7c5f5cd 100644 --- a/src/playbackmanager.js +++ b/src/playbackmanager.js @@ -52,7 +52,7 @@ function seek (toSeek = 0) { if (getAudioDispatcher()) { startPlaying(undefined, undefined, ticksToSeconds(toSeek), _disconnectOnFinish); jellyfinClientManager.getJellyfinClient().reportPlaybackProgress(getProgressPayload()); - }else{ + } else { throw Error("No Song Playing"); } } diff --git a/src/util.js b/src/util.js index 1bf5259..1a48f71 100644 --- a/src/util.js +++ b/src/util.js @@ -7,16 +7,16 @@ function ticksToSeconds (ticks) { return ticks / 10000000; } -function hmsToSeconds(str) { - var p = str.split(':'), - s = 0, m = 1; +function hmsToSeconds (str) { + var p = str.split(":"); + var s = 0; var m = 1; - while (p.length > 0) { - s += m * parseInt(p.pop(), 10); - m *= 60; - } + while (p.length > 0) { + s += m * parseInt(p.pop(), 10); + m *= 60; + } - return s; + return s; } module.exports = {