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
84ff83ede0
commit
5d6a88860c
19
src/index.js
19
src/index.js
@ -10,32 +10,31 @@ try {
|
|||||||
handleChannelMessage
|
handleChannelMessage
|
||||||
} = require("./messagehandler");
|
} = require("./messagehandler");
|
||||||
const log = require("loglevel");
|
const log = require("loglevel");
|
||||||
const prefix = require('loglevel-plugin-prefix');
|
const prefix = require("loglevel-plugin-prefix");
|
||||||
const chalk = require('chalk');
|
const chalk = require("chalk");
|
||||||
const colors = {
|
const colors = {
|
||||||
TRACE: chalk.magenta,
|
TRACE: chalk.magenta,
|
||||||
DEBUG: chalk.cyan,
|
DEBUG: chalk.cyan,
|
||||||
INFO: chalk.blue,
|
INFO: chalk.blue,
|
||||||
WARN: chalk.yellow,
|
WARN: chalk.yellow,
|
||||||
ERROR: chalk.red,
|
ERROR: chalk.red
|
||||||
};
|
};
|
||||||
|
|
||||||
log.setLevel(CONFIG["log-level"]);
|
log.setLevel(CONFIG["log-level"]);
|
||||||
|
|
||||||
|
|
||||||
prefix.reg(log);
|
prefix.reg(log);
|
||||||
log.enableAll();
|
log.enableAll();
|
||||||
|
|
||||||
prefix.apply(log, {
|
prefix.apply(log, {
|
||||||
format(level, name, timestamp) {
|
format (level, name, timestamp) {
|
||||||
return `${chalk.gray(`[${timestamp}]`)} ${colors[level.toUpperCase()](level)} ${chalk.green(`${name}:`)}`;
|
return `${chalk.gray(`[${timestamp}]`)} ${colors[level.toUpperCase()](level)} ${chalk.green(`${name}:`)}`;
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
prefix.apply(log.getLogger('critical'), {
|
prefix.apply(log.getLogger("critical"), {
|
||||||
format(level, name, timestamp) {
|
format (level, name, timestamp) {
|
||||||
return chalk.red.bold(`[${timestamp}] ${level} ${name}:`);
|
return chalk.red.bold(`[${timestamp}] ${level} ${name}:`);
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
jellyfinClientManager.init();
|
jellyfinClientManager.init();
|
||||||
@ -51,4 +50,4 @@ try {
|
|||||||
discordClient.login(CONFIG.token);
|
discordClient.login(CONFIG.token);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ function streamURLbuilder (itemID, bitrate) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function startPlaying (voiceconnection = discordclientmanager.getDiscordClient().user.client.voice.connections.first(), itemIDPlaylist = currentPlayingPlaylist, playlistIndex = currentPlayingPlaylistIndex, seekTo, disconnectOnFinish = _disconnectOnFinish) {
|
function startPlaying (voiceconnection = discordclientmanager.getDiscordClient().user.client.voice.connections.first(), itemIDPlaylist = currentPlayingPlaylist, playlistIndex = currentPlayingPlaylistIndex, seekTo, disconnectOnFinish = _disconnectOnFinish) {
|
||||||
log.debug("start playing ",playlistIndex, ". of list: ",itemIDPlaylist," in a voiceconnection?: ", typeof voiceconnection !== "undefined");
|
log.debug("start playing ", playlistIndex, ". of list: ", itemIDPlaylist, " in a voiceconnection?: ", typeof voiceconnection !== "undefined");
|
||||||
isPaused = false;
|
isPaused = false;
|
||||||
currentPlayingPlaylist = itemIDPlaylist;
|
currentPlayingPlaylist = itemIDPlaylist;
|
||||||
currentPlayingPlaylistIndex = playlistIndex;
|
currentPlayingPlaylistIndex = playlistIndex;
|
||||||
@ -57,8 +57,7 @@ function startPlaying (voiceconnection = discordclientmanager.getDiscordClient()
|
|||||||
|
|
||||||
getAudioDispatcher().on("finish", () => {
|
getAudioDispatcher().on("finish", () => {
|
||||||
if (isRepeat) {
|
if (isRepeat) {
|
||||||
|
log.debug("repeat and sending following payload as reportPlaybackStopped to the server: ", getStopPayload());
|
||||||
log.debug("repeat and sending following payload as reportPlaybackStopped to the server: ",getStopPayload());
|
|
||||||
jellyfinClientManager.getJellyfinClient().reportPlaybackStopped(getStopPayload());
|
jellyfinClientManager.getJellyfinClient().reportPlaybackStopped(getStopPayload());
|
||||||
startPlaying(voiceconnection, undefined, currentPlayingPlaylistIndex, 0);
|
startPlaying(voiceconnection, undefined, currentPlayingPlaylistIndex, 0);
|
||||||
} else {
|
} else {
|
||||||
@ -69,7 +68,7 @@ function startPlaying (voiceconnection = discordclientmanager.getDiscordClient()
|
|||||||
stop(undefined, currentPlayingPlaylist[playlistIndex - 1]);
|
stop(undefined, currentPlayingPlaylist[playlistIndex - 1]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.debug("repeat and sending following payload as reportPlaybackStopped to the server: ",getStopPayload());
|
log.debug("repeat and sending following payload as reportPlaybackStopped to the server: ", getStopPayload());
|
||||||
jellyfinClientManager.getJellyfinClient().reportPlaybackStopped(getStopPayload());
|
jellyfinClientManager.getJellyfinClient().reportPlaybackStopped(getStopPayload());
|
||||||
startPlaying(voiceconnection, undefined, currentPlayingPlaylistIndex + 1, 0);
|
startPlaying(voiceconnection, undefined, currentPlayingPlaylistIndex + 1, 0);
|
||||||
}
|
}
|
||||||
@ -82,7 +81,7 @@ function startPlaying (voiceconnection = discordclientmanager.getDiscordClient()
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function spawnPlayMessage (message) {
|
async function spawnPlayMessage (message) {
|
||||||
log.debug("spawned Play Message?: ",typeof message !== "undefined");
|
log.debug("spawned Play Message?: ", typeof message !== "undefined");
|
||||||
const itemIdDetails = await jellyfinClientManager.getJellyfinClient().getItem(jellyfinClientManager.getJellyfinClient().getCurrentUserId(), getItemId());
|
const itemIdDetails = await jellyfinClientManager.getJellyfinClient().getItem(jellyfinClientManager.getJellyfinClient().getCurrentUserId(), getItemId());
|
||||||
const imageURL = await jellyfinClientManager.getJellyfinClient().getImageUrl(itemIdDetails.AlbumId || getItemId(), { type: "Primary" });
|
const imageURL = await jellyfinClientManager.getJellyfinClient().getImageUrl(itemIdDetails.AlbumId || getItemId(), { type: "Primary" });
|
||||||
try {
|
try {
|
||||||
@ -129,7 +128,7 @@ function seek (toSeek = 0) {
|
|||||||
* @param {Array} itemID - array of itemIDs to be added
|
* @param {Array} itemID - array of itemIDs to be added
|
||||||
*/
|
*/
|
||||||
function addTracks (itemID) {
|
function addTracks (itemID) {
|
||||||
log.debug("added track: ",itemID);
|
log.debug("added track: ", itemID);
|
||||||
currentPlayingPlaylist = currentPlayingPlaylist.concat(itemID);
|
currentPlayingPlaylist = currentPlayingPlaylist.concat(itemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +140,7 @@ function nextTrack () {
|
|||||||
throw Error("This is the Last song");
|
throw Error("This is the Last song");
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug("sending following payload as reportPlaybackStopped to the server: ",getStopPayload());
|
log.debug("sending following payload as reportPlaybackStopped to the server: ", getStopPayload());
|
||||||
jellyfinClientManager.getJellyfinClient().reportPlaybackStopped(getStopPayload());
|
jellyfinClientManager.getJellyfinClient().reportPlaybackStopped(getStopPayload());
|
||||||
|
|
||||||
startPlaying(undefined, undefined, currentPlayingPlaylistIndex + 1, 0, _disconnectOnFinish);
|
startPlaying(undefined, undefined, currentPlayingPlaylistIndex + 1, 0, _disconnectOnFinish);
|
||||||
@ -157,7 +156,7 @@ function previousTrack () {
|
|||||||
throw Error("This is the First song");
|
throw Error("This is the First song");
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug("sending following payload as reportPlaybackStopped to the server: ",getStopPayload());
|
log.debug("sending following payload as reportPlaybackStopped to the server: ", getStopPayload());
|
||||||
jellyfinClientManager.getJellyfinClient().reportPlaybackStopped(getStopPayload());
|
jellyfinClientManager.getJellyfinClient().reportPlaybackStopped(getStopPayload());
|
||||||
|
|
||||||
startPlaying(undefined, undefined, currentPlayingPlaylistIndex - 1, 0, _disconnectOnFinish);
|
startPlaying(undefined, undefined, currentPlayingPlaylistIndex - 1, 0, _disconnectOnFinish);
|
||||||
@ -168,7 +167,6 @@ function previousTrack () {
|
|||||||
* @param {Object=} disconnectVoiceConnection - Optional The voice Connection do disconnect from
|
* @param {Object=} disconnectVoiceConnection - Optional The voice Connection do disconnect from
|
||||||
*/
|
*/
|
||||||
function stop (disconnectVoiceConnection, itemId = getItemId()) {
|
function stop (disconnectVoiceConnection, itemId = getItemId()) {
|
||||||
|
|
||||||
isPaused = true;
|
isPaused = true;
|
||||||
if (interactivemsghandler.hasMessage()) {
|
if (interactivemsghandler.hasMessage()) {
|
||||||
interactivemsghandler.destroy();
|
interactivemsghandler.destroy();
|
||||||
@ -176,7 +174,7 @@ function stop (disconnectVoiceConnection, itemId = getItemId()) {
|
|||||||
if (disconnectVoiceConnection) {
|
if (disconnectVoiceConnection) {
|
||||||
disconnectVoiceConnection.disconnect();
|
disconnectVoiceConnection.disconnect();
|
||||||
}
|
}
|
||||||
log.debug("stop playback and send following payload as reportPlaybackStopped to the server: ",getStopPayload());
|
log.debug("stop playback and send following payload as reportPlaybackStopped to the server: ", getStopPayload());
|
||||||
jellyfinClientManager.getJellyfinClient().reportPlaybackStopped(getStopPayload());
|
jellyfinClientManager.getJellyfinClient().reportPlaybackStopped(getStopPayload());
|
||||||
if (getAudioDispatcher()) {
|
if (getAudioDispatcher()) {
|
||||||
try {
|
try {
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
function checkJellyfinItemIDRegex (strgintomatch) {
|
function checkJellyfinItemIDRegex (strgintomatch) {
|
||||||
const regexresult = strgintomatch.match(/([0-9]|[a-f]){32}/);
|
const regexresult = strgintomatch.match(/([0-9]|[a-f]){32}/);
|
||||||
if(regexresult)
|
if (regexresult) { return [regexresult[0]]; } else { return undefined; }
|
||||||
return [regexresult[0]];
|
|
||||||
else
|
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function ticksToSeconds (ticks) {
|
function ticksToSeconds (ticks) {
|
||||||
|
Loading…
Reference in New Issue
Block a user