From 84ad94a83ad71ec09bea7913783f4517f8b4de33 Mon Sep 17 00:00:00 2001 From: KGT1 Date: Thu, 8 Oct 2020 06:42:23 +0200 Subject: [PATCH 1/5] fix parseENV not parseing ENV --- parseENV.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/parseENV.js b/parseENV.js index e28c92f..a88f41b 100644 --- a/parseENV.js +++ b/parseENV.js @@ -2,13 +2,13 @@ const fs = require("fs"); const filename = "./config.json"; const configfile = require(filename); -if (!configfile["discord-prefix"]) { configfile["discord-prefix"] = process.env.DISCORD_PREFIX; } -if (!configfile.token) { configfile.token = process.env.DISCORD_TOKEN; } -if (!configfile["server-adress"]) { configfile["server-adress"] = process.env.JELLYFIN_SERVER_ADDRESS; } -if (!configfile["jellyfin-username"]) { configfile["jellyfin-username"] = process.env.JELLYFIN_USERNAME; } -if (!configfile["jellyfin-password"]) { configfile["jellyfin-password"] = process.env.JELLYFIN_PASSWORD; } -if (!configfile["jellyfin-app-name"]) { configfile["jellyfin-app-name"] = process.env.JELLYFIN_APP_NAME; } -if (!configfile["interactive-seek-bar-update-intervall"]) { configfile["interactive-seek-bar-update-intervall"] = parseInt(process.env.MESSAGE_UPDATE_INTERVAL); } +if (process.env.DISCORD_PREFIX) { configfile["discord-prefix"] = process.env.DISCORD_PREFIX; } +if (process.env.DISCORD_TOKEN) { configfile.token = process.env.DISCORD_TOKEN; } +if (process.env.JELLYFIN_SERVER_ADDRESS) { configfile["server-adress"] = process.env.JELLYFIN_SERVER_ADDRESS; } +if (process.env.JELLYFIN_USERNAME) { configfile["jellyfin-username"] = process.env.JELLYFIN_USERNAME; } +if (process.env.JELLYFIN_PASSWORD) { configfile["jellyfin-password"] = process.env.JELLYFIN_PASSWORD; } +if (process.env.JELLYFIN_APP_NAME) { configfile["jellyfin-app-name"] = process.env.JELLYFIN_APP_NAME; } +if (process.env.MESSAGE_UPDATE_INTERVAL) { configfile["interactive-seek-bar-update-intervall"] = parseInt(process.env.MESSAGE_UPDATE_INTERVAL); } fs.writeFile(filename, JSON.stringify(configfile, null, 1), (err) => { if (err) return console.error(err); From 2645511d9f7ca299a21c8b7c15f680874f857472 Mon Sep 17 00:00:00 2001 From: artiume Date: Sun, 25 Oct 2020 21:23:26 -0400 Subject: [PATCH 2/5] Full Guide to make the bot not sure if you want this in the ReadMe, a different link or dont want it at all, but I thought I would give back some for the awesome bot :) --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index d45cb5c..f93bd53 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,31 @@ You'll need a Discord Application for this Bot to work, as you will host it your [How to invite the Bot to your server](https://discordjs.guide/preparations/adding-your-bot-to-servers.html#bot-invite-links) +[Generate an Api and bot here](https://discord.com/developers/applications/). + +Click New Application. + +![image](https://user-images.githubusercontent.com/20715731/97124506-bba00080-1706-11eb-820a-035039484ca2.png) + +The Name of the application will be the bot's name. + +![image](https://user-images.githubusercontent.com/20715731/97124528-d2deee00-1706-11eb-8a05-8b0542e1213a.png) + +Go to the Bot tab. + +![image](https://user-images.githubusercontent.com/20715731/97124557-ef7b2600-1706-11eb-8fed-2373df9a1eb7.png) + +Generate the bot, and grab the token. Also, recommend making the bot private. + +![image](https://user-images.githubusercontent.com/20715731/97124639-484abe80-1707-11eb-92f9-1182aad3d2d2.png) + +Go to the OAuth2 page, click Bot Scope to get the url authorization link. + +![image](https://user-images.githubusercontent.com/20715731/97124754-b68f8100-1707-11eb-9e16-f84401d108bf.png) + +Authorize your room! + +![image](https://user-images.githubusercontent.com/20715731/97124818-08380b80-1708-11eb-944a-f96395dcf6c1.png) ### The simplest way to get started is using Docker: From ea61bfbaa9d977ec160cc41cea3223b5baf7856a Mon Sep 17 00:00:00 2001 From: KGT1 Date: Mon, 26 Oct 2020 10:17:50 +0100 Subject: [PATCH 3/5] fix not sending track stop on next or previous track --- src/playbackmanager.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/playbackmanager.js b/src/playbackmanager.js index 88fc29b..b04761e 100644 --- a/src/playbackmanager.js +++ b/src/playbackmanager.js @@ -114,6 +114,14 @@ function seek (toSeek = 0) { throw Error("No Song Playing"); } } + +function currentTrackStopped (itemId) { + jellyfinClientManager.getJellyfinClient().reportPlaybackStopped({ + userId: jellyfinClientManager.getJellyfinClient().getCurrentUserId(), + itemId: itemId, + playSessionId: getPlaySessionId() + }); +} /** * * @param {Array} itemID - array of itemIDs to be added @@ -123,12 +131,12 @@ function addTracks (itemID) { } function nextTrack () { - // console.log(currentPlayingPlaylistIndex + 1, currentPlayingPlaylist.length); if (!(currentPlayingPlaylist)) { throw Error("There is currently nothing playing"); } else if (currentPlayingPlaylistIndex + 1 >= currentPlayingPlaylist.length) { throw Error("This is the Last song"); } + currentTrackStopped(getItemId()); startPlaying(undefined, undefined, currentPlayingPlaylistIndex + 1, 0, _disconnectOnFinish); } @@ -140,6 +148,7 @@ function previousTrack () { startPlaying(undefined, undefined, currentPlayingPlaylistIndex, 0, _disconnectOnFinish); throw Error("This is the First song"); } + currentTrackStopped(getItemId()); startPlaying(undefined, undefined, currentPlayingPlaylistIndex - 1, 0, _disconnectOnFinish); } } @@ -155,11 +164,7 @@ function stop (disconnectVoiceConnection, itemId = getItemId()) { if (disconnectVoiceConnection) { disconnectVoiceConnection.disconnect(); } - jellyfinClientManager.getJellyfinClient().reportPlaybackStopped({ - userId: jellyfinClientManager.getJellyfinClient().getCurrentUserId(), - itemId: itemId, - playSessionId: getPlaySessionId() - }); + currentTrackStopped(itemId); if (getAudioDispatcher()) { try { getAudioDispatcher().destroy(); From 00259a2619ea725059a899b8b96581bcff949e3d Mon Sep 17 00:00:00 2001 From: artiume Date: Mon, 26 Oct 2020 08:00:40 -0400 Subject: [PATCH 4/5] Update README.md --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f93bd53..0900cec 100644 --- a/README.md +++ b/README.md @@ -42,10 +42,6 @@ help | Display the help message ## Getting Started You'll need a Discord Application for this Bot to work, as you will host it yourself. -[How to retrieve your token](https://discordjs.guide/preparations/setting-up-a-bot-application.html#creating-your-bot) - -[How to invite the Bot to your server](https://discordjs.guide/preparations/adding-your-bot-to-servers.html#bot-invite-links) - [Generate an Api and bot here](https://discord.com/developers/applications/). Click New Application. @@ -72,6 +68,12 @@ Authorize your room! ![image](https://user-images.githubusercontent.com/20715731/97124818-08380b80-1708-11eb-944a-f96395dcf6c1.png) +For official documentation + +[How to retrieve your token](https://discordjs.guide/preparations/setting-up-a-bot-application.html#creating-your-bot) + +[How to invite the Bot to your server](https://discordjs.guide/preparations/adding-your-bot-to-servers.html#bot-invite-links) + ### The simplest way to get started is using Docker: ```bash From 455f7392ce18dcd3e821d049c8822c8983b3f025 Mon Sep 17 00:00:00 2001 From: artiume Date: Mon, 26 Oct 2020 08:06:34 -0400 Subject: [PATCH 5/5] Update README.md --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0900cec..c288b75 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,13 @@ Authorize your room! ![image](https://user-images.githubusercontent.com/20715731/97124818-08380b80-1708-11eb-944a-f96395dcf6c1.png) -For official documentation +Next, join a voice channel and connect your bot with ?summon. This will connect your bot to the voice channel you're in and will create the device profile in Jellyfin. + +![Image to Discord Play to Window](img/playtowindow.png) + +From within Jellyfin, start playing content or from within Discord, use the bot commands to start enjoying music! + +For official documentation to creating a bot. [How to retrieve your token](https://discordjs.guide/preparations/setting-up-a-bot-application.html#creating-your-bot)