From 0f5022df15c91e04c1df4107257577d93ab7e347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Fri, 17 Sep 2021 13:07:43 +0300 Subject: [PATCH 1/4] Bumb Version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index d49e66c..a9d44ef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "eximiabots-radiox", - "version": "0.3.9", + "version": "0.3.10", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "eximiabots-radiox", - "version": "0.3.9", + "version": "0.3.10", "license": "MIT", "dependencies": { "@discordjs/builders": "^0.6.0", diff --git a/package.json b/package.json index e88cfe4..a238af8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eximiabots-radiox", - "version": "0.3.9", + "version": "0.3.10", "description": "Internet Radio to your Discord guild", "main": "index.js", "scripts": { From dc7b14b11acc8e06323952292dc4dab31ba773e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Fri, 17 Sep 2021 23:14:24 +0300 Subject: [PATCH 2/4] Fix Stations class bug --- src/client/classes/Stations.js | 16 +++++++++------- src/client/events/ready.js | 6 ++++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/client/classes/Stations.js b/src/client/classes/Stations.js index 76493f5..fdd7668 100644 --- a/src/client/classes/Stations.js +++ b/src/client/classes/Stations.js @@ -15,16 +15,18 @@ module.exports = class Stations extends Array { .then(response => response.json()); if(list){ - this.logger('Stations'); - this.forEach(oldStation => { - if(list.findIndex(station => station.name == oldStation.name)) return; - delete this[this.findIndex(station => station.name == oldStation.name)]; - }); + this.length = 0; list.forEach(station => { - console.log("- " + station.name); this.push(station); }); - console.log("\n"); + + if(options.show){ + this.logger('Stations'); + list.forEach(station => { + console.log("- " + station.name); + }); + console.log("\n"); + } } this.logger('Stations', 'Successfully fetched list'); diff --git a/src/client/events/ready.js b/src/client/events/ready.js index 8ffcd6e..ccae145 100644 --- a/src/client/events/ready.js +++ b/src/client/events/ready.js @@ -42,12 +42,14 @@ module.exports = { client.stations = new Stations(); await client.stations.fetch({ - url: client.config.stationslistUrl + url: client.config.stationslistUrl, + show: true }); setInterval(async () => { await client.stations.fetch({ - url: client.config.stationslistUrl + url: client.config.stationslistUrl, + show: false }); }, 3600000); From 57aaf92947dd40a5b5b1ffec916ab7421994ba61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Fri, 17 Sep 2021 23:24:48 +0300 Subject: [PATCH 3/4] Prevent loadState function updating datastore entries everytime --- src/client/funcs/loadState.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/client/funcs/loadState.js b/src/client/funcs/loadState.js index 676685e..d56c275 100644 --- a/src/client/funcs/loadState.js +++ b/src/client/funcs/loadState.js @@ -4,6 +4,8 @@ module.exports = function loadState(client, guild){ let state; state = data.state; + if(!state) return; + data.state = {}; client.datastore.updateEntry(guild, data); return state; From 871cb475f9ca95cbf542902424f0e21a26e79c6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Fri, 17 Sep 2021 23:29:04 +0300 Subject: [PATCH 4/4] Streamlined restore method in Radio class with play command --- src/client/classes/Radio.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/client/classes/Radio.js b/src/client/classes/Radio.js index ca0af5b..64c67a1 100644 --- a/src/client/classes/Radio.js +++ b/src/client/classes/Radio.js @@ -65,18 +65,8 @@ module.exports = class Radio extends Map { construct.connection = connection; let date = new Date(); construct.startTime = date.getTime(); - - client.funcs.play(client, null, guild, station); - client.datastore.checkEntry(guild.id); - construct.datastore = client.datastore.getEntry(guild.id); - - if (!construct.datastore.statistics[construct.station.name]) { - construct.datastore.statistics[construct.station.name] = {}; - construct.datastore.statistics[construct.station.name].time = 0; - construct.datastore.statistics[construct.station.name].used = 0; - client.datastore.updateEntry(guild, construct.datastore); - } + client.funcs.play(client, null, guild, station); } catch (error) { console.log(error); }