This commit is contained in:
KGT1 2020-09-23 17:42:13 +02:00
parent db6638724c
commit a719ccecd9
3 changed files with 12 additions and 13 deletions

View File

@ -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);

View File

@ -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");
}
}

View File

@ -7,9 +7,9 @@ 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);