mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-23 18:21:55 +01:00
fix lint
This commit is contained in:
parent
e019f4c6e5
commit
0fe1c80f88
@ -3,9 +3,6 @@ const Discord = require("discord.js");
|
||||
const {
|
||||
checkJellyfinItemIDRegex
|
||||
} = require("./util");
|
||||
const {
|
||||
getAudioDispatcher
|
||||
} = require("./dispachermanager");
|
||||
const {
|
||||
hmsToSeconds
|
||||
} = require("./util");
|
||||
@ -20,7 +17,7 @@ var isSummendByPlay = false;
|
||||
|
||||
// random Color of the Jellyfin Logo Gradient
|
||||
function getRandomDiscordColor () {
|
||||
let random = Math.random();
|
||||
const random = Math.random();
|
||||
function randomNumber (b, a) {
|
||||
return Math.floor(random * Math.pow(Math.pow((b - a), 2), 1 / 2)) + (b > a ? a : b);
|
||||
}
|
||||
@ -186,7 +183,7 @@ function handleChannelMessage (message) {
|
||||
}
|
||||
} else if (message.content.startsWith(CONFIG["discord-prefix"] + "skip")) {
|
||||
try {
|
||||
playbackmanager.nextTrack()
|
||||
playbackmanager.nextTrack();
|
||||
} catch (error) {
|
||||
const errorMessage = getDiscordEmbedError(error);
|
||||
message.channel.send(errorMessage);
|
||||
|
@ -7,7 +7,6 @@ const {
|
||||
ticksToSeconds
|
||||
} = require("./util");
|
||||
|
||||
|
||||
// this whole thing should be a class but its probably too late now.
|
||||
|
||||
var currentPlayingPlaylist;
|
||||
@ -52,16 +51,13 @@ function startPlaying(voiceconnection = discordclientmanager.getDiscordClient().
|
||||
|
||||
getAudioDispatcher().on("finish", () => {
|
||||
if (currentPlayingPlaylist.length < playlistIndex) {
|
||||
console.log("PLAYLIST END")
|
||||
|
||||
if (disconnectOnFinish) {
|
||||
stop(voiceconnection, currentPlayingPlaylist[playlistIndex - 1]);
|
||||
} else {
|
||||
stop(undefined, currentPlayingPlaylist[playlistIndex - 1]);
|
||||
}
|
||||
|
||||
} else {
|
||||
startPlaying(voiceconnection, itemIDPlaylist, currentPlayingPlaylistIndex+1, 0)
|
||||
startPlaying(voiceconnection, itemIDPlaylist, currentPlayingPlaylistIndex + 1, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -88,19 +84,18 @@ function nextTrack(){
|
||||
} else if (currentPlayingPlaylistIndex + 1 >= currentPlayingPlaylist.length) {
|
||||
throw Error("This is the Last song");
|
||||
}
|
||||
startPlaying(undefined, undefined, currentPlayingPlaylistIndex + 1, 0, _disconnectOnFinish)
|
||||
startPlaying(undefined, undefined, currentPlayingPlaylistIndex + 1, 0, _disconnectOnFinish);
|
||||
}
|
||||
|
||||
function previousTrack () {
|
||||
if (ticksToSeconds(getPostitionTicks()) < 10) {
|
||||
console.log(currentPlayingPlaylistIndex , currentPlayingPlaylist.length);
|
||||
if (!(currentPlayingPlaylist)) {
|
||||
throw Error("There is currently nothing playing");
|
||||
} else if (currentPlayingPlaylistIndex - 1 < 0) {
|
||||
startPlaying(undefined, undefined, currentPlayingPlaylistIndex, 0, _disconnectOnFinish)
|
||||
startPlaying(undefined, undefined, currentPlayingPlaylistIndex, 0, _disconnectOnFinish);
|
||||
throw Error("This is the First song");
|
||||
}
|
||||
startPlaying(undefined, undefined, currentPlayingPlaylistIndex - 1, 0, _disconnectOnFinish)
|
||||
startPlaying(undefined, undefined, currentPlayingPlaylistIndex - 1, 0, _disconnectOnFinish);
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,8 +103,6 @@ function previousTrack(){
|
||||
* @param {Object=} disconnectVoiceConnection - Optional The voice Connection do disconnect from
|
||||
*/
|
||||
function stop (disconnectVoiceConnection, itemId = getItemId()) {
|
||||
console.log("im getting called");
|
||||
console
|
||||
isPaused = true;
|
||||
if (disconnectVoiceConnection) {
|
||||
disconnectVoiceConnection.disconnect();
|
||||
@ -151,7 +144,6 @@ function playPause() {
|
||||
|
||||
function getPostitionTicks () {
|
||||
// this is very sketchy but i dont know how else to do it
|
||||
console.log((_seek + getAudioDispatcher().streamTime - getAudioDispatcher().pausedTime) * 10000);
|
||||
return (_seek + getAudioDispatcher().streamTime - getAudioDispatcher().pausedTime) * 10000;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@ function openSocket () {
|
||||
}
|
||||
);
|
||||
jellyfinClientManager.getJellyfinEvents().on(jellyfinClientManager.getJellyfinClient(), "message", (type, data) => {
|
||||
console.log(data);
|
||||
if (data.MessageType === "Play") {
|
||||
if (data.Data.PlayCommand === "PlayNow") {
|
||||
playbackmanager.startPlaying(undefined, data.Data.ItemIds, data.Data.StartIndex || 0, 0, false);
|
||||
@ -24,7 +23,7 @@ function openSocket () {
|
||||
playbackmanager.stop();
|
||||
} else if (data.Data.Command === "Seek") {
|
||||
// because the server sends seek an privious track at same time so i have to do timing
|
||||
setTimeout(async()=>{playbackmanager.seek(data.Data.SeekPositionTicks);},20)
|
||||
setTimeout(async () => { playbackmanager.seek(data.Data.SeekPositionTicks); }, 20);
|
||||
} else if (data.Data.Command === "NextTrack") {
|
||||
try {
|
||||
playbackmanager.nextTrack();
|
||||
@ -33,7 +32,6 @@ function openSocket () {
|
||||
}
|
||||
} else if (data.Data.Command === "PreviousTrack") {
|
||||
try {
|
||||
console.log(ticksToSeconds(playbackmanager.getPostitionTicks())<10,ticksToSeconds(playbackmanager.getPostitionTicks()),` (${playbackmanager.getPostitionTicks()})`," < ",10)
|
||||
if (ticksToSeconds(playbackmanager.getPostitionTicks()) < 10) {
|
||||
playbackmanager.previousTrack();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user