This commit is contained in:
KGT1 2020-10-06 00:47:26 +02:00
parent 927049f9a4
commit 9ec2d2aa73
4 changed files with 34 additions and 38 deletions

View File

@ -126,7 +126,6 @@ class InterActivePlayMessage {
updateProgress (ticks) { updateProgress (ticks) {
if (typeof this.musicplayermessage !== "undefined" && typeof this.musicplayermessage.embeds[0] !== "undefined" && typeof this.musicplayermessage.embeds[0].fields[0] !== "undefined") { if (typeof this.musicplayermessage !== "undefined" && typeof this.musicplayermessage.embeds[0] !== "undefined" && typeof this.musicplayermessage.embeds[0].fields[0] !== "undefined") {
this.musicplayermessage.embeds[0].fields[0] = { this.musicplayermessage.embeds[0].fields[0] = {
name: getProgressString(ticks / this.ticksLength), name: getProgressString(ticks / this.ticksLength),
value: `${secondsToHms(ticksToSeconds(ticks))} / ${secondsToHms(ticksToSeconds(this.ticksLength))}`, value: `${secondsToHms(ticksToSeconds(ticks))} / ${secondsToHms(ticksToSeconds(this.ticksLength))}`,

View File

@ -57,16 +57,17 @@ async function searchForItemID (searchString) {
case "Audio": case "Audio":
return [response.SearchHints[0].ItemId]; return [response.SearchHints[0].ItemId];
case "Playlist": case "Playlist":
case "MusicAlbum": case "MusicAlbum": {
let resp = await jellyfinClientManager.getJellyfinClient().getItems(jellyfinClientManager.getJellyfinClient().getCurrentUserId(),{sortBy:"SortName", sortOrder:"Ascending",parentId:response.SearchHints[0].ItemId}); const resp = await jellyfinClientManager.getJellyfinClient().getItems(jellyfinClientManager.getJellyfinClient().getCurrentUserId(), { sortBy: "SortName", sortOrder: "Ascending", parentId: response.SearchHints[0].ItemId });
let itemArray = []; const itemArray = [];
resp.Items.forEach(element => { resp.Items.forEach(element => {
itemArray.push(element.Id) itemArray.push(element.Id);
}); });
return itemArray; return itemArray;
} }
} }
} }
}
function summon (voiceChannel) { function summon (voiceChannel) {
voiceChannel.join(); voiceChannel.join();
@ -126,7 +127,6 @@ async function addThis (message) {
} else { } else {
try { try {
items = await searchForItemID(argument); items = await searchForItemID(argument);
console.log(items);
} catch (e) { } catch (e) {
const noSong = getDiscordEmbedError(e); const noSong = getDiscordEmbedError(e);
message.channel.send(noSong); message.channel.send(noSong);
@ -204,12 +204,10 @@ function handleChannelMessage (message) {
message.channel.send(errorMessage); message.channel.send(errorMessage);
} }
} else if (message.content.startsWith(CONFIG["discord-prefix"] + "add")) { } else if (message.content.startsWith(CONFIG["discord-prefix"] + "add")) {
const indexOfArgument = message.content.indexOf(CONFIG["discord-prefix"] + "add") + (CONFIG["discord-prefix"] + "add").length + 1;
const argument = message.content.slice(indexOfArgument);
addThis(message); addThis(message);
} else if (message.content.startsWith(CONFIG["discord-prefix"] + "spawn")) { } else if (message.content.startsWith(CONFIG["discord-prefix"] + "spawn")) {
try { try {
playbackmanager.spawnPlayMessage(message) playbackmanager.spawnPlayMessage(message);
} catch (error) { } catch (error) {
const errorMessage = getDiscordEmbedError(error); const errorMessage = getDiscordEmbedError(error);
message.channel.send(errorMessage); message.channel.send(errorMessage);

View File

@ -54,7 +54,7 @@ function startPlaying (voiceconnection = discordclientmanager.getDiscordClient()
getAudioDispatcher().on("finish", () => { getAudioDispatcher().on("finish", () => {
if (isRepeat) { if (isRepeat) {
startPlaying(voiceconnection,undefined,currentPlayingPlaylistIndex,0) startPlaying(voiceconnection, undefined, currentPlayingPlaylistIndex, 0);
} else { } else {
if (currentPlayingPlaylist.length < playlistIndex) { if (currentPlayingPlaylist.length < playlistIndex) {
if (disconnectOnFinish) { if (disconnectOnFinish) {
@ -64,7 +64,8 @@ function startPlaying (voiceconnection = discordclientmanager.getDiscordClient()
} }
} else { } else {
startPlaying(voiceconnection, undefined, currentPlayingPlaylistIndex + 1, 0); startPlaying(voiceconnection, undefined, currentPlayingPlaylistIndex + 1, 0);
}} }
}
}); });
} }
playasync().catch((rsn) => { playasync().catch((rsn) => {
@ -83,7 +84,7 @@ async function spawnPlayMessage (message) {
playPause, playPause,
() => { stop(_disconnectOnFinish ? discordclientmanager.getDiscordClient().user.client.voice.connections.first() : undefined); }, () => { stop(_disconnectOnFinish ? discordclientmanager.getDiscordClient().user.client.voice.connections.first() : undefined); },
nextTrack, nextTrack,
()=>{setIsRepeat(!isRepeat)}, () => { setIsRepeat(!isRepeat); },
currentPlayingPlaylist.length); currentPlayingPlaylist.length);
if (typeof CONFIG["interactive-seek-bar-update-intervall"] === "number") { if (typeof CONFIG["interactive-seek-bar-update-intervall"] === "number") {
interactivemsghandler.startUpate(getPostitionTicks); interactivemsghandler.startUpate(getPostitionTicks);
@ -99,7 +100,6 @@ async function updatePlayMessage () {
const imageURL = await jellyfinClientManager.getJellyfinClient().getImageUrl(itemIdDetails.AlbumId, { type: "Primary" }); const imageURL = await jellyfinClientManager.getJellyfinClient().getImageUrl(itemIdDetails.AlbumId, { type: "Primary" });
interactivemsghandler.updateCurrentSongMessage(itemIdDetails.Name, itemIdDetails.Artists[0] || "VA", imageURL, interactivemsghandler.updateCurrentSongMessage(itemIdDetails.Name, itemIdDetails.Artists[0] || "VA", imageURL,
`${jellyfinClientManager.getJellyfinClient().serverAddress()}/web/index.html#!/details?id=${itemIdDetails.AlbumId}`, itemIdDetails.RunTimeTicks, currentPlayingPlaylistIndex + 1, currentPlayingPlaylist.length); `${jellyfinClientManager.getJellyfinClient().serverAddress()}/web/index.html#!/details?id=${itemIdDetails.AlbumId}`, itemIdDetails.RunTimeTicks, currentPlayingPlaylistIndex + 1, currentPlayingPlaylist.length);
} }
} }
@ -263,7 +263,6 @@ function setIsRepeat (arg) {
isRepeat = !isRepeat; isRepeat = !isRepeat;
} }
} }
console.log("img being called and setting",arg,isRepeat);
isRepeat = arg; isRepeat = arg;
} }