From e2ebe6a36ebccf233540b2d7a9ec42e864436085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Fri, 10 Sep 2021 02:33:56 +0300 Subject: [PATCH 001/105] 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 b3d384d..4a18b84 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "eximiabots-radiox", - "version": "0.3.8", + "version": "0.3.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "eximiabots-radiox", - "version": "0.3.8", + "version": "0.3.9", "license": "MIT", "dependencies": { "@discordjs/builders": "^0.6.0", diff --git a/package.json b/package.json index d394755..c497c88 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eximiabots-radiox", - "version": "0.3.8", + "version": "0.3.9", "description": "Internet Radio to your Discord guild", "main": "index.js", "scripts": { From a5eec44b8e12ecd86fb099693f3dbbe6bc003e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Fri, 10 Sep 2021 03:13:40 +0300 Subject: [PATCH 002/105] Fix maintenance command --- src/client/commands/maintenance.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/commands/maintenance.js b/src/client/commands/maintenance.js index 8f7745e..8f87e7c 100644 --- a/src/client/commands/maintenance.js +++ b/src/client/commands/maintenance.js @@ -126,7 +126,7 @@ module.exports = { case "8": client.user.setStatus('dnd'); client.funcs.logger("Maintenance Mode", "Enabled"); - client.config.maintenance = false; + client.config.maintenance = true; break; case "9": client.user.setStatus('online'); From 0b8fb4977ceab0c063acf8ddea9130cf5b4cd878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Fri, 10 Sep 2021 03:17:22 +0300 Subject: [PATCH 003/105] Update maintenance command --- src/client/commands/maintenance.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/client/commands/maintenance.js b/src/client/commands/maintenance.js index 8f87e7c..949f8ce 100644 --- a/src/client/commands/maintenance.js +++ b/src/client/commands/maintenance.js @@ -93,23 +93,30 @@ module.exports = { switch(action){ case "0": + client.config.maintenance = true; process.emit('SIGINT'); break; case "4": + client.config.maintenance = true; client.user.setStatus('idle'); client.funcs.saveRadios(client); client.user.setStatus('online'); + client.config.maintenance = false; break; case "5": + client.config.maintenance = true; client.user.setStatus('idle'); let guilds = await client.guilds.fetch(); client.funcs.restoreRadios(client, guilds); client.user.setStatus('online'); + client.config.maintenance = false; break; case "6": + client.config.maintenance = true; client.user.setStatus('idle'); require(`../commands.js`).execute(client); client.user.setStatus('online'); + client.config.maintenance = false; break; case "7": try { From b9e1945719a32b7f94a02bf4e98b127b83af6598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Fri, 10 Sep 2021 23:23:29 +0300 Subject: [PATCH 004/105] Update Dependencies --- package-lock.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4a18b84..a51f5da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -447,9 +447,9 @@ } }, "node_modules/@sindresorhus/is": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.0.1.tgz", - "integrity": "sha512-Qm9hBEBu18wt1PO2flE7LPb30BHMQt1eQgbV76YntdNk73XZGpn3izvGTYxbGgzXKgbCjiia0uxTd3aTNQrY/g==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.1.0.tgz", + "integrity": "sha512-Cgva8HxclecUCmAImsWsbZGUh6p5DSzQ8l2Uzxuj9ANiD7LVhLM1UJ2hX/R2Y+ILpvqgW9QjmTCaBkXtj8+UOg==", "engines": { "node": ">=10" }, @@ -1799,9 +1799,9 @@ "dev": true }, "node_modules/fastq": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.12.0.tgz", - "integrity": "sha512-VNX0QkHK3RsXVKr9KrlUv/FoTa0NdbYoHHl7uXHv2rzyHSlxjdNAKug2twd9luJxpcyNeAgf5iPPMutJO67Dfg==", + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", + "integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==", "dev": true, "dependencies": { "reusify": "^1.0.4" @@ -4325,9 +4325,9 @@ "integrity": "sha512-gPSOQKmEWeuif2ftmW7gyToCnOoqpDqTSNrxX7HsoMwGNLtrT9p5DHcQolkBg5CEK3ooDFy5DNEFKUshQU7vyQ==" }, "@sindresorhus/is": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.0.1.tgz", - "integrity": "sha512-Qm9hBEBu18wt1PO2flE7LPb30BHMQt1eQgbV76YntdNk73XZGpn3izvGTYxbGgzXKgbCjiia0uxTd3aTNQrY/g==" + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.1.0.tgz", + "integrity": "sha512-Cgva8HxclecUCmAImsWsbZGUh6p5DSzQ8l2Uzxuj9ANiD7LVhLM1UJ2hX/R2Y+ILpvqgW9QjmTCaBkXtj8+UOg==" }, "@szmarczak/http-timer": { "version": "1.1.2", @@ -5317,9 +5317,9 @@ "dev": true }, "fastq": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.12.0.tgz", - "integrity": "sha512-VNX0QkHK3RsXVKr9KrlUv/FoTa0NdbYoHHl7uXHv2rzyHSlxjdNAKug2twd9luJxpcyNeAgf5iPPMutJO67Dfg==", + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", + "integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==", "dev": true, "requires": { "reusify": "^1.0.4" From 57f63c3838c41250d7e870cd98fb7fc15b3fd899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Fri, 10 Sep 2021 23:25:48 +0300 Subject: [PATCH 005/105] Move Datastore class to src/client/classes folder --- src/Client.ts | 2 +- src/client/{datastore.js => classes/Datastore.js} | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) rename src/client/{datastore.js => classes/Datastore.js} (92%) diff --git a/src/Client.ts b/src/Client.ts index 70e0095..7bd7c7f 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -1,6 +1,6 @@ import Discord, { Client, Collection } from "discord.js"; import fs from "fs"; -import Datastore from "./client/datastore.js"; +import Datastore from "./client/classes/Datastore.js"; import { command, radio } from "./client/utils/typings.js"; import config from "./config.js"; import messages from "./client/messages.js"; diff --git a/src/client/datastore.js b/src/client/classes/Datastore.js similarity index 92% rename from src/client/datastore.js rename to src/client/classes/Datastore.js index 4db0eee..89c2751 100644 --- a/src/client/datastore.js +++ b/src/client/classes/Datastore.js @@ -8,15 +8,15 @@ module.exports = class { } loadData() { - const dir = path.join(path.dirname(__dirname), '../datastore'); + const dir = path.join(path.dirname(__dirname), '../../datastore'); if (!fs.existsSync(dir)) { fs.mkdirSync(dir); } //console.log(""); - const dataFiles = fs.readdirSync(path.join(path.dirname(__dirname), '../datastore')).filter(f => f.endsWith('.json')); + const dataFiles = fs.readdirSync(path.join(path.dirname(__dirname), '../../datastore')).filter(f => f.endsWith('.json')); for (const file of dataFiles) { try { - const json = require(`../../datastore/${file}`); + const json = require(`../../../datastore/${file}`); this.map.set(json.guild.id, json); //console.log('[LOADED] ' + file + " (" + json.guild.id + ")"); //console.log(JSON.stringify(json, null, 4)); @@ -127,7 +127,7 @@ module.exports = class { saveEntry(file, data) { data = JSON.stringify(data, null, 4); - fs.writeFile(path.join(path.dirname(__dirname), '../datastore') + "/" + file + ".json", data, 'utf8', function(err) { + fs.writeFile(path.join(path.dirname(__dirname), '../../datastore') + "/" + file + ".json", data, 'utf8', function(err) { if (err) { //console.log(err); } From 24eaf3a7e2386b72d2cf6b34ce152d3a221fc814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Fri, 10 Sep 2021 23:41:48 +0300 Subject: [PATCH 006/105] Update ready.js --- src/client/events/ready.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/events/ready.js b/src/client/events/ready.js index ccc6a66..25ed614 100644 --- a/src/client/events/ready.js +++ b/src/client/events/ready.js @@ -1,4 +1,4 @@ -import Datastore from "../datastore.js"; +import Datastore from "../classes/Datastore.js"; const _importDynamic = new Function('modulePath', 'return import(modulePath)'); const fetch = (...args) => _importDynamic('node-fetch').then(({default: fetch}) => fetch(...args)); From d8daacf80e0e6d3f3d09360d9e3844474fbba610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 15:12:29 +0300 Subject: [PATCH 007/105] Updated Dependencies --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index a51f5da..2d11c6c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3735,9 +3735,9 @@ } }, "node_modules/typescript": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.2.tgz", - "integrity": "sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==", + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz", + "integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -6742,9 +6742,9 @@ } }, "typescript": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.2.tgz", - "integrity": "sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==", + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz", + "integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==", "dev": true }, "undefsafe": { From 45923319a67e49cc235db66a779d0704d2cccef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 17:10:37 +0300 Subject: [PATCH 008/105] Create Radio class --- src/client/classes/Radio.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/client/classes/Radio.js diff --git a/src/client/classes/Radio.js b/src/client/classes/Radio.js new file mode 100644 index 0000000..e371498 --- /dev/null +++ b/src/client/classes/Radio.js @@ -0,0 +1,10 @@ +module.exports = class { + constructor() { + this.map = new Map(); + this.example(); + } + + example() { + + } +}; From 8bf79c27442bda0b13ce757ba490096eec42a724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 17:10:50 +0300 Subject: [PATCH 009/105] Create Streamer class --- src/client/classes/Streamer.js | 61 ++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/client/classes/Streamer.js diff --git a/src/client/classes/Streamer.js b/src/client/classes/Streamer.js new file mode 100644 index 0000000..1749cee --- /dev/null +++ b/src/client/classes/Streamer.js @@ -0,0 +1,61 @@ +const { + createAudioPlayer, + createAudioResource +} = require("@discordjs/voice"); +const { + logger +} = require("../funcs/logger.js"); + +module.exports = class { + constructor() { + this.map = new Map(); + this.stations = null; + } + + init(client){ + if(!client.stations) return; + + client.stations.forEach(station => { + const url = station.stream[station.stream.default]; + this.play(station); + }); + } + + + play(station) { + const audioPlayer = createAudioPlayer(); + const resource = createAudioResource(url); + audioPlayer.play(resource); + resource.playStream + .on("readable", () => { + logger('Streamer', station.name + " / " + "Readable"); + this.map.set(station.name, audioPlayer); + }) + .on("finish", () => { + logger('Streamer', station.name + " / " + "Finished"); + this.map.delete(station.name); + }) + .on("error", error => { + logger('Streamer', station.name + " / " + "Error"); + this.map.delete(station.name); + }); + } + + listen(station) { + let audioPlayer = this.map.get(station.name); + if(!audioPlayer){ + this.play(station); + } + return audioPlayer; + } + + leave(client) { + if(!client.stations) return; + + client.stations.forEach(station => { + let streamer = this.map.get(station.name); + streamer?.stop(); + this.map.delete(station.name); + }); + } +}; From 2b72f8725658901fb9ad296d190662379b46134a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 17:11:10 +0300 Subject: [PATCH 010/105] Update Client.ts --- src/Client.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Client.ts b/src/Client.ts index 7bd7c7f..af0c835 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -1,6 +1,8 @@ import Discord, { Client, Collection } from "discord.js"; -import fs from "fs"; import Datastore from "./client/classes/Datastore.js"; +import Radio from "./client/classes/Radio.js"; +import Streamer from "./client/classes/Streamer.js"; +import fs from "fs"; import { command, radio } from "./client/utils/typings.js"; import config from "./config.js"; import messages from "./client/messages.js"; @@ -22,6 +24,7 @@ class RadioClient extends Client { readonly config = config; readonly messages = messages; public datastore: Datastore | null; + public streamer: Streamer | null; constructor() { super({ intents: GatewayIntents @@ -29,6 +32,7 @@ class RadioClient extends Client { this.commands = new Collection(); this.radio = new Map(); this.datastore = null; + this.streamer = null; this.funcs = {}; this.funcs.check = require("./client/funcs/check.js"); From 1533ae46a448eefd16dac4b95484eab9d05e9aef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 17:12:53 +0300 Subject: [PATCH 011/105] Update voiceStateUpdate event --- src/client/events/voiceStateUpdate.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/client/events/voiceStateUpdate.js b/src/client/events/voiceStateUpdate.js index e6da785..283e1d6 100644 --- a/src/client/events/voiceStateUpdate.js +++ b/src/client/events/voiceStateUpdate.js @@ -16,7 +16,6 @@ module.exports = { if (newState.channel === null) { client.funcs.statisticsUpdate(client, newState.guild, radio); radio.connection?.destroy(); - radio.audioPlayer?.stop(); radio.message?.delete(); client.funcs.logger('Radio', 'Stream stopped' + " / " + newState.guild.id); return client.radio.delete(newState.guild.id); @@ -39,7 +38,6 @@ module.exports = { } catch (error) { client.funcs.statisticsUpdate(client, newState.guild, radio); radio.connection?.destroy(); - radio.audioPlayer?.stop(); radio.message?.delete(); client.funcs.logger('Radio', 'Stream stopped' + " / " + newState.guild.id); client.radio.delete(oldState.guild.id); @@ -59,7 +57,6 @@ module.exports = { if (radio.voiceChannel.members.size === 1) { client.funcs.statisticsUpdate(client, newState.guild, radio); radio.connection?.destroy(); - radio.audioPlayer?.stop(); radio.message?.delete(); client.funcs.logger('Radio', 'Stream stopped' + " / " + newState.guild.id); client.radio.delete(newState.guild.id); From 05905e6e6d042b5faf37cdb25748bcbb54e7535d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 17:13:47 +0300 Subject: [PATCH 012/105] Update restoreRadios function --- src/client/funcs/restoreRadios.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/client/funcs/restoreRadios.js b/src/client/funcs/restoreRadios.js index 10aff24..15432d3 100644 --- a/src/client/funcs/restoreRadios.js +++ b/src/client/funcs/restoreRadios.js @@ -1,6 +1,5 @@ import Discord from "discord.js"; const { - createAudioPlayer, getVoiceConnection, joinVoiceChannel } = require("@discordjs/voice"); @@ -26,7 +25,6 @@ module.exports = async function restoreRadios(client, guilds) { voiceChannel: client.channels.cache.get(state.channels.voice), connection: null, message: null, - audioPlayer: createAudioPlayer(), station: station }; client.radio.set(guild.id, construct); @@ -44,7 +42,7 @@ module.exports = async function restoreRadios(client, guilds) { let date = new Date(); construct.startTime = date.getTime(); - client.funcs.play(null, guild, client, url, Discord); + client.funcs.play(client, null, guild, station); client.datastore.checkEntry(guild.id); construct.datastore = client.datastore.getEntry(guild.id); From 26eda76b23ab4b113f450e5c3fbaa57e276c027e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 17:14:02 +0300 Subject: [PATCH 013/105] Update saveRadios function --- src/client/funcs/saveRadios.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/client/funcs/saveRadios.js b/src/client/funcs/saveRadios.js index 9e7b187..af84efa 100644 --- a/src/client/funcs/saveRadios.js +++ b/src/client/funcs/saveRadios.js @@ -10,7 +10,6 @@ module.exports = function saveRadios(client) { client.funcs.statisticsUpdate(client, currentRadio.guild, currentRadio); client.funcs.saveState(client, currentRadio.guild, currentRadio); currentRadio.connection?.destroy(); - currentRadio.audioPlayer?.stop(); currentRadio.message?.delete(); client.radio.delete(radio.value); } From 3d066435b4f0ee50119087340a109364e20e1ba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 17:14:21 +0300 Subject: [PATCH 014/105] Update SIGINT event --- src/client/events/SIGINT.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/client/events/SIGINT.js b/src/client/events/SIGINT.js index 6445029..66ac2c4 100644 --- a/src/client/events/SIGINT.js +++ b/src/client/events/SIGINT.js @@ -3,6 +3,7 @@ module.exports = { execute(client) { client.user.setStatus('dnd'); + client.streamer.stop(client); client.funcs.saveRadios(client); setInterval(() => { From fcf6f15be95322c65dce34c3b010d3e9b805dc7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 17:14:43 +0300 Subject: [PATCH 015/105] Update ready event --- src/client/events/ready.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/client/events/ready.js b/src/client/events/ready.js index 25ed614..e19b1d9 100644 --- a/src/client/events/ready.js +++ b/src/client/events/ready.js @@ -1,4 +1,6 @@ import Datastore from "../classes/Datastore.js"; +import Radio from "../classes/Radio.js"; +import Streamer from "../classes/Streamer.js"; const _importDynamic = new Function('modulePath', 'return import(modulePath)'); const fetch = (...args) => _importDynamic('node-fetch').then(({default: fetch}) => fetch(...args)); @@ -69,6 +71,12 @@ module.exports = { } }, 3600000); + client.streamer = new Streamer(); + + if(client.stations){ + await client.streamer.init(client); + } + if(!client.stations) { client.user.setStatus('dnd'); } @@ -100,9 +108,11 @@ module.exports = { }, 5000); setTimeout(function () { - /*MAINTENANCE MODE*/ - client.funcs.logger("Maintenance Mode", "Disabled"); - client.config.maintenance = false; + if(client.stations) { + /*MAINTENANCE MODE*/ + client.funcs.logger("Maintenance Mode", "Disabled"); + client.config.maintenance = false; + } }, 10000); } From 645ea3e1975452caf3eced526e9bcc9ba13de8a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 17:14:55 +0300 Subject: [PATCH 016/105] Update prev command --- src/client/commands/prev.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/client/commands/prev.js b/src/client/commands/prev.js index 78ac583..3db911b 100644 --- a/src/client/commands/prev.js +++ b/src/client/commands/prev.js @@ -16,10 +16,7 @@ module.exports = { ephemeral: true }); - let url = station.stream[station.stream.default]; - client.funcs.statisticsUpdate(client, interaction.guild, radio); - radio.audioPlayer.stop(); let date = new Date(); radio.station = station; @@ -27,11 +24,11 @@ module.exports = { radio.startTime = date.getTime(); if(interaction.isCommand()) { - client.funcs.play(interaction, interaction.guild, client, url); + client.funcs.play(client, interaction, interaction.guild, station); } if(interaction.isButton()) { interaction.deferUpdate(); - client.funcs.play(null, interaction.guild, client, url); + client.funcs.play(client, null, interaction.guild, station); } } From 13ae6c2716d0589f6dd3ec6ef58b3c42365fd426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 17:15:04 +0300 Subject: [PATCH 017/105] Update next command --- src/client/commands/next.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/client/commands/next.js b/src/client/commands/next.js index ab3a0f0..345faa7 100644 --- a/src/client/commands/next.js +++ b/src/client/commands/next.js @@ -16,10 +16,7 @@ module.exports = { ephemeral: true }); - let url = station.stream[station.stream.default]; - client.funcs.statisticsUpdate(client, interaction.guild, radio); - radio.audioPlayer.stop(); let date = new Date(); radio.station = station; @@ -27,13 +24,12 @@ module.exports = { radio.startTime = date.getTime(); if(interaction.isCommand()) { - client.funcs.play(interaction, interaction.guild, client, url); + client.funcs.play(client, interaction, interaction.guild, station); } if(interaction.isButton()) { interaction.deferUpdate(); - client.funcs.play(null, interaction.guild, client, url); + client.funcs.play(client, null, interaction.guild, station); } - } } } From 73d330d1e2921445afdc0468962b1a7b32bef76d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 17:15:27 +0300 Subject: [PATCH 018/105] Update stop command --- src/client/commands/stop.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/client/commands/stop.js b/src/client/commands/stop.js index dd6174f..fff1748 100644 --- a/src/client/commands/stop.js +++ b/src/client/commands/stop.js @@ -9,8 +9,7 @@ module.exports = { const radio = client.radio.get(interaction.guild.id); client.funcs.statisticsUpdate(client, interaction.guild, radio); radio.connection?.destroy(); - radio.audioPlayer?.stop(); - client.funcs.logger('Radio', 'Stream stopped' + " / " + interaction.guild.id); + client.funcs.logger('Radio', interaction.guild.id + " / " + 'Stop'); const embed = new Discord.MessageEmbed() .setTitle(client.user.username) From 9517ba1fa92a0d41ccc34592b989fb57a50c944e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 17:16:03 +0300 Subject: [PATCH 019/105] Update play function --- src/client/funcs/play.js | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/src/client/funcs/play.js b/src/client/funcs/play.js index 464e242..9653f13 100644 --- a/src/client/funcs/play.js +++ b/src/client/funcs/play.js @@ -3,35 +3,12 @@ const { createAudioResource } = require("@discordjs/voice"); -module.exports = async function play(interaction, guild, client, url) { +module.exports = async function play(client, interaction, guild, station) { let message = {}; const radio = client.radio.get(guild.id); - const resource = createAudioResource(url); - radio.connection.subscribe(radio.audioPlayer); - radio.audioPlayer.play(resource); - resource.playStream - .on("readable", () => { - client.funcs.logger('Radio', 'Stream started' + " / " + guild.id + " / " + radio.station.name); - }) - .on("finish", () => { - client.funcs.logger('Radio', 'Stream finished' + " / " + guild.id); - client.funcs.statisticsUpdate(client, guild, radio); - radio.connection?.destroy(); - radio.audioPlayer?.stop(); - client.radio.delete(guild.id); - return; - }) - .on("error", error => { - client.funcs.logger('Radio', 'Stream errored'); - console.error(error); - radio.connection?.destroy(); - radio.audioPlayer?.stop(); - client.radio.delete(guild.id); - return interaction.reply({ - content: client.messages.errorPlaying, - ephemeral: true - }); - }); + const audioPlayer = client.streamer.listen(station); + radio.connection.subscribe(audioPlayer); + client.funcs.logger('Radio', guild.id + " / " + "Play" + " / " + radio.station.name); message.nowplayingDescription = client.messages.nowplayingDescription.replace("%radio.station.name%", radio.station.name); message.nowplayingDescription = message.nowplayingDescription.replace("%radio.station.owner%", radio.station.owner); From b4a24de8cd510228c2a22411da9a5dd3adf0cf7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 17:16:11 +0300 Subject: [PATCH 020/105] Update play command --- src/client/commands/play.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/client/commands/play.js b/src/client/commands/play.js index cdbd6b4..3184e8f 100644 --- a/src/client/commands/play.js +++ b/src/client/commands/play.js @@ -1,5 +1,4 @@ const { - createAudioPlayer, getVoiceConnection, joinVoiceChannel } = require("@discordjs/voice"); @@ -79,7 +78,6 @@ module.exports = { ephemeral: true }); } else { - url = client.stations[number].stream[client.stations[number].stream.default]; station = client.stations[number]; } } else { @@ -92,19 +90,17 @@ module.exports = { content: client.messageEmojis["error"] + client.messages.noSearchResults, ephemeral: true }); - url = sstation.stream[sstation.stream.default]; station = sstation; } if (radio) { client.funcs.statisticsUpdate(client, interaction.guild, radio); - radio.audioPlayer.stop(); let date = new Date(); radio.station = station; radio.textChannel = interaction.channel; radio.startTime = date.getTime(); - client.funcs.play(interaction, interaction.guild, client, url); + client.funcs.play(client, interaction, interaction.guild, station); return; } @@ -114,7 +110,6 @@ module.exports = { voiceChannel: voiceChannel, connection: null, message: null, - audioPlayer: createAudioPlayer(), station: station }; client.radio.set(interaction.guild.id, construct); @@ -130,7 +125,7 @@ module.exports = { construct.connection = connection; let date = new Date(); construct.startTime = date.getTime(); - client.funcs.play(interaction, interaction.guild, client, url); + client.funcs.play(client, interaction, interaction.guild, station); client.datastore.checkEntry(interaction.guild.id); construct.currentGuild = client.datastore.getEntry(interaction.guild.id); From b66a60ebe903b8ff8bc7c6a9404f6e818a1d0c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 17:17:42 +0300 Subject: [PATCH 021/105] Formatting Streamer class --- src/client/classes/Streamer.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/client/classes/Streamer.js b/src/client/classes/Streamer.js index 1749cee..4ddc216 100644 --- a/src/client/classes/Streamer.js +++ b/src/client/classes/Streamer.js @@ -21,7 +21,6 @@ module.exports = class { }); } - play(station) { const audioPlayer = createAudioPlayer(); const resource = createAudioResource(url); From 0bc26f8895c3abd8edc44140ec0afe1bf7e8846e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 17:34:50 +0300 Subject: [PATCH 022/105] Update Streamer class --- src/client/classes/Streamer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/classes/Streamer.js b/src/client/classes/Streamer.js index 4ddc216..90c3b02 100644 --- a/src/client/classes/Streamer.js +++ b/src/client/classes/Streamer.js @@ -16,12 +16,12 @@ module.exports = class { if(!client.stations) return; client.stations.forEach(station => { - const url = station.stream[station.stream.default]; this.play(station); }); } play(station) { + const url = station.stream[station.stream.default]; const audioPlayer = createAudioPlayer(); const resource = createAudioResource(url); audioPlayer.play(resource); From 12f3948e40917a74d2c185c8036bd67f5f2d7bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 17:35:20 +0300 Subject: [PATCH 023/105] Update SIGINT event --- src/client/events/SIGINT.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/events/SIGINT.js b/src/client/events/SIGINT.js index 66ac2c4..1360c58 100644 --- a/src/client/events/SIGINT.js +++ b/src/client/events/SIGINT.js @@ -3,7 +3,7 @@ module.exports = { execute(client) { client.user.setStatus('dnd'); - client.streamer.stop(client); + client.streamer.leave(client); client.funcs.saveRadios(client); setInterval(() => { From bfec178de7cbc636aba48a01dd56e4d1166d9c7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 18:01:53 +0300 Subject: [PATCH 024/105] Update Streamer class --- src/client/classes/Streamer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/client/classes/Streamer.js b/src/client/classes/Streamer.js index 90c3b02..ed500f4 100644 --- a/src/client/classes/Streamer.js +++ b/src/client/classes/Streamer.js @@ -38,12 +38,13 @@ module.exports = class { logger('Streamer', station.name + " / " + "Error"); this.map.delete(station.name); }); + return audioPlayer; } listen(station) { let audioPlayer = this.map.get(station.name); if(!audioPlayer){ - this.play(station); + audioPlayer = this.play(station); } return audioPlayer; } From a043cde46e46096cc2a1e9f98448a5e776286424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 18:03:27 +0300 Subject: [PATCH 025/105] Update logger function --- src/client/funcs/logger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/funcs/logger.js b/src/client/funcs/logger.js index 610fdc5..ec39d1a 100644 --- a/src/client/funcs/logger.js +++ b/src/client/funcs/logger.js @@ -1,4 +1,4 @@ -module.exports = function (area, text){ +module.exports = function logger(area, text){ let date = new Date(); console.log('[' + area + '] – ' + date.toISOString()); if(text) console.log(text + '\n'); From 095b6ad77521521d000a479bd49ef39e28d0335c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 18:27:01 +0300 Subject: [PATCH 026/105] Update Streamer class --- src/client/classes/Streamer.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/client/classes/Streamer.js b/src/client/classes/Streamer.js index ed500f4..437a479 100644 --- a/src/client/classes/Streamer.js +++ b/src/client/classes/Streamer.js @@ -2,14 +2,12 @@ const { createAudioPlayer, createAudioResource } = require("@discordjs/voice"); -const { - logger -} = require("../funcs/logger.js"); module.exports = class { constructor() { this.map = new Map(); this.stations = null; + this.logger = require("../funcs/logger.js"); } init(client){ @@ -27,15 +25,15 @@ module.exports = class { audioPlayer.play(resource); resource.playStream .on("readable", () => { - logger('Streamer', station.name + " / " + "Readable"); + this.logger('Streamer', station.name + " / " + "Readable"); this.map.set(station.name, audioPlayer); }) .on("finish", () => { - logger('Streamer', station.name + " / " + "Finished"); + this.logger('Streamer', station.name + " / " + "Finished"); this.map.delete(station.name); }) .on("error", error => { - logger('Streamer', station.name + " / " + "Error"); + this.logger('Streamer', station.name + " / " + "Error"); this.map.delete(station.name); }); return audioPlayer; From 9019741146c8292bade89a6681535b177b88751e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 18:27:12 +0300 Subject: [PATCH 027/105] Update stop command --- src/client/commands/stop.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/client/commands/stop.js b/src/client/commands/stop.js index fff1748..84674fc 100644 --- a/src/client/commands/stop.js +++ b/src/client/commands/stop.js @@ -22,7 +22,11 @@ module.exports = { if(!radio.message){ radio.message = radio.textChannel.send({ embeds: [embed], components: [] }); } else { - radio.message.edit({ embeds: [embed], components: [] }); + if(radio.textChannel.id == radio.message.channel.id){ + radio.message.edit({ embeds: [embed], components: [] }); + } else { + radio.message?.delete(); + } } setTimeout(async function() { From 1cfa62802f547b175a886d59a177db16f6250939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 18:27:21 +0300 Subject: [PATCH 028/105] Update play command --- src/client/funcs/play.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/client/funcs/play.js b/src/client/funcs/play.js index 9653f13..cbab028 100644 --- a/src/client/funcs/play.js +++ b/src/client/funcs/play.js @@ -60,7 +60,12 @@ module.exports = async function play(client, interaction, guild, station) { if(!radio.message){ radio.message = await radio.textChannel.send({ embeds: [embed], components: [buttons] }); } else { - radio.message.edit({ embeds: [embed], components: [buttons] }); + if(radio.textChannel.id == radio.message.channel.id){ + radio.message.edit({ embeds: [embed], components: [buttons] }); + } else { + radio.message?.delete(); + radio.message = await radio.textChannel.send({ embeds: [embed], components: [buttons] }); + } } message.play = client.messages.play.replace("%radio.station.name%", radio.station.name); From accff3fa6059edb465a005019a4ef36be31698b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 22:35:06 +0300 Subject: [PATCH 029/105] Update Streamer class --- src/client/classes/Streamer.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/client/classes/Streamer.js b/src/client/classes/Streamer.js index 437a479..5350e0a 100644 --- a/src/client/classes/Streamer.js +++ b/src/client/classes/Streamer.js @@ -14,13 +14,15 @@ module.exports = class { if(!client.stations) return; client.stations.forEach(station => { + const audioPlayer = createAudioPlayer(); + this.map.set(station.name, audioPlayer); this.play(station); }); } play(station) { + const audioPlayer = this.map.get(station.name); const url = station.stream[station.stream.default]; - const audioPlayer = createAudioPlayer(); const resource = createAudioResource(url); audioPlayer.play(resource); resource.playStream @@ -31,10 +33,12 @@ module.exports = class { .on("finish", () => { this.logger('Streamer', station.name + " / " + "Finished"); this.map.delete(station.name); + this.play(station); }) .on("error", error => { this.logger('Streamer', station.name + " / " + "Error"); this.map.delete(station.name); + this.play(station); }); return audioPlayer; } From 0c76c137b92d79b5c3c51fc1e941b88a1e7fff0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 23:02:12 +0300 Subject: [PATCH 030/105] Update ready.js --- src/client/events/ready.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/client/events/ready.js b/src/client/events/ready.js index e19b1d9..403b725 100644 --- a/src/client/events/ready.js +++ b/src/client/events/ready.js @@ -72,10 +72,7 @@ module.exports = { }, 3600000); client.streamer = new Streamer(); - - if(client.stations){ - await client.streamer.init(client); - } + client.streamer.init(client); if(!client.stations) { client.user.setStatus('dnd'); From 824d4042c10164c60f297ca1790bc16f1758b248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 23:02:37 +0300 Subject: [PATCH 031/105] Update maintenance command --- src/client/commands/maintenance.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/client/commands/maintenance.js b/src/client/commands/maintenance.js index 949f8ce..de6d185 100644 --- a/src/client/commands/maintenance.js +++ b/src/client/commands/maintenance.js @@ -126,6 +126,9 @@ module.exports = { .then(response => response.json()); client.funcs.logger('Stations', 'Successfully fetched list'); + + client.streamer.refresh(client); + } catch (error) { client.funcs.logger('Stations', 'Fetching list failed'); } From 49475212a732ddd2c658e86a4b0f02967a588c22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 23:03:20 +0300 Subject: [PATCH 032/105] Update Streamer class --- src/client/classes/Streamer.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/client/classes/Streamer.js b/src/client/classes/Streamer.js index 5350e0a..b807d39 100644 --- a/src/client/classes/Streamer.js +++ b/src/client/classes/Streamer.js @@ -14,12 +14,19 @@ module.exports = class { if(!client.stations) return; client.stations.forEach(station => { - const audioPlayer = createAudioPlayer(); - this.map.set(station.name, audioPlayer); + let audioPlayer = this.map.get(station.name); + if(!audioPlayer) { + audioPlayer = createAudioPlayer(); + this.map.set(station.name, audioPlayer); + } this.play(station); }); } + refresh(client){ + this.init(client); + } + play(station) { const audioPlayer = this.map.get(station.name); const url = station.stream[station.stream.default]; From ffa9c8abb0718dd583f077cb871b9ef05ffaec31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 23:12:39 +0300 Subject: [PATCH 033/105] Update Streamer class --- src/client/classes/Streamer.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/client/classes/Streamer.js b/src/client/classes/Streamer.js index b807d39..8622264 100644 --- a/src/client/classes/Streamer.js +++ b/src/client/classes/Streamer.js @@ -25,6 +25,12 @@ module.exports = class { refresh(client){ this.init(client); + + let streamers = this.map.keys(); + streamers.forEach(streamer => { + if(client.stations.findIndex(station => station.name == streamer)) return; + this.map.delete(streamer); + }); } play(station) { From 7d479b4c5fdd69b5742e59a758f8f0090bf9ead1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 23:19:49 +0300 Subject: [PATCH 034/105] Update Streamer class --- src/client/classes/Streamer.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/client/classes/Streamer.js b/src/client/classes/Streamer.js index 8622264..ee8df57 100644 --- a/src/client/classes/Streamer.js +++ b/src/client/classes/Streamer.js @@ -29,7 +29,7 @@ module.exports = class { let streamers = this.map.keys(); streamers.forEach(streamer => { if(client.stations.findIndex(station => station.name == streamer)) return; - this.map.delete(streamer); + this.stop(streamer); }); } @@ -56,6 +56,12 @@ module.exports = class { return audioPlayer; } + stop(station){ + let audioPlayer = this.map.get(station.name); + audioPlayer?.stop(); + this.map.delete(station.name); + } + listen(station) { let audioPlayer = this.map.get(station.name); if(!audioPlayer){ @@ -68,9 +74,7 @@ module.exports = class { if(!client.stations) return; client.stations.forEach(station => { - let streamer = this.map.get(station.name); - streamer?.stop(); - this.map.delete(station.name); + this.stop(station); }); } }; From 803bc20fb7bddffcc06af12c0d3c905a2d279e1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 23:58:24 +0300 Subject: [PATCH 035/105] Update voiceStateUpdate event --- src/client/events/voiceStateUpdate.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/events/voiceStateUpdate.js b/src/client/events/voiceStateUpdate.js index 283e1d6..3eeb658 100644 --- a/src/client/events/voiceStateUpdate.js +++ b/src/client/events/voiceStateUpdate.js @@ -17,7 +17,7 @@ module.exports = { client.funcs.statisticsUpdate(client, newState.guild, radio); radio.connection?.destroy(); radio.message?.delete(); - client.funcs.logger('Radio', 'Stream stopped' + " / " + newState.guild.id); + client.funcs.logger('Radio', newState.guild.id + " / " + 'Stop'); return client.radio.delete(newState.guild.id); } @@ -39,7 +39,7 @@ module.exports = { client.funcs.statisticsUpdate(client, newState.guild, radio); radio.connection?.destroy(); radio.message?.delete(); - client.funcs.logger('Radio', 'Stream stopped' + " / " + newState.guild.id); + client.funcs.logger('Radio', newState.guild.id + " / " + 'Stop'); client.radio.delete(oldState.guild.id); } return; @@ -58,7 +58,7 @@ module.exports = { client.funcs.statisticsUpdate(client, newState.guild, radio); radio.connection?.destroy(); radio.message?.delete(); - client.funcs.logger('Radio', 'Stream stopped' + " / " + newState.guild.id); + client.funcs.logger('Radio', newState.guild.id + " / " + 'Stop'); client.radio.delete(newState.guild.id); } }, 60000); From ad9a2f8f19bb3d3bb76e8e8102ec15977f274750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 23:58:39 +0300 Subject: [PATCH 036/105] Update restoreRadios function --- src/client/funcs/restoreRadios.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/client/funcs/restoreRadios.js b/src/client/funcs/restoreRadios.js index 15432d3..b83243f 100644 --- a/src/client/funcs/restoreRadios.js +++ b/src/client/funcs/restoreRadios.js @@ -17,7 +17,6 @@ module.exports = async function restoreRadios(client, guilds) { const sstation = await client.funcs.searchStation(state.station.name, client); - let url = sstation.stream[sstation.stream.default]; let station = sstation; const construct = { From 727f8f517797f301346a735d03ccc148b91d2e57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sun, 12 Sep 2021 16:48:11 +0300 Subject: [PATCH 037/105] Update Dependencies --- package-lock.json | 6 +++--- package.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2d11c6c..22f23b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ "path": "^0.12.7" }, "devDependencies": { - "@types/node": "^16.9.0", + "@types/node": "^16.9.1", "@types/ws": "^7.4.7", "@typescript-eslint/eslint-plugin": "^4.31.0", "@typescript-eslint/parser": "^4.31.0", @@ -29,14 +29,14 @@ "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", "nodemon": "^2.0.12", - "prettier": "^2.3.2", + "prettier": "^2.4.0", "rimraf": "^3.0.2", "ts-node": "^10.2.1", "tsc-watch": "^4.5.0", "typescript": "^4.4.2" }, "engines": { - "node": ">=16.8.0", + "node": ">=16.9.0", "npm": ">=7.0.0" } }, diff --git a/package.json b/package.json index c497c88..cbd39c2 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "path": "^0.12.7" }, "devDependencies": { - "@types/node": "^16.9.0", + "@types/node": "^16.9.1", "@types/ws": "^7.4.7", "@typescript-eslint/eslint-plugin": "^4.31.0", "@typescript-eslint/parser": "^4.31.0", @@ -38,14 +38,14 @@ "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", "nodemon": "^2.0.12", - "prettier": "^2.3.2", + "prettier": "^2.4.0", "rimraf": "^3.0.2", "ts-node": "^10.2.1", "tsc-watch": "^4.5.0", "typescript": "^4.4.2" }, "engines": { - "node": ">=16.8.0", + "node": ">=16.9.0", "npm": ">=7.0.0" } } From e85b86417063616642c61fa95cb7238dd6ad7a3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sun, 12 Sep 2021 17:07:41 +0300 Subject: [PATCH 038/105] Add streamerMode setting to config --- src/config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/config.js b/src/config.js index b161603..dd005d8 100644 --- a/src/config.js +++ b/src/config.js @@ -22,5 +22,6 @@ module.exports = { //Settings version: process.env.RADIOX_VERSION || process.env.npm_package_version, debug: process.env.DEBUG_MODE || false, - maintenance: false + maintenance: false, + streamerMode: process.env.STREAMER_MODE || "auto" } From 86510a88713cc173c13a5cd66add83effc4659d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sun, 12 Sep 2021 17:08:20 +0300 Subject: [PATCH 039/105] Hide owner in now playing when station name is same in nowplaying command --- src/client/commands/nowplaying.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/client/commands/nowplaying.js b/src/client/commands/nowplaying.js index b863dc5..1914c2d 100644 --- a/src/client/commands/nowplaying.js +++ b/src/client/commands/nowplaying.js @@ -15,7 +15,11 @@ module.exports = { const completed = (radio.playTime); message.nowplayingDescription = client.messages.nowplayingDescription.replace("%radio.station.name%", radio.station.name); - message.nowplayingDescription = message.nowplayingDescription.replace("%radio.station.owner%", radio.station.owner); + if(radio.station.name != radio.station.owner){ + message.nowplayingDescription = message.nowplayingDescription.replace("%radio.station.owner%", radio.station.owner); + } else { + message.nowplayingDescription = message.nowplayingDescription.replace("%radio.station.owner%" + "\n", ""); + } message.nowplayingDescription = message.nowplayingDescription.replace("%client.funcs.msToTime(completed)%", client.funcs.msToTime(completed)); const embed = new Discord.MessageEmbed() From 3029a8a653b2d2fbfe9900356f696f4f5b9cb6d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sun, 12 Sep 2021 17:08:31 +0300 Subject: [PATCH 040/105] Hide owner in now playing when station name is same in play command --- src/client/funcs/play.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/client/funcs/play.js b/src/client/funcs/play.js index cbab028..2d4048e 100644 --- a/src/client/funcs/play.js +++ b/src/client/funcs/play.js @@ -11,7 +11,11 @@ module.exports = async function play(client, interaction, guild, station) { client.funcs.logger('Radio', guild.id + " / " + "Play" + " / " + radio.station.name); message.nowplayingDescription = client.messages.nowplayingDescription.replace("%radio.station.name%", radio.station.name); - message.nowplayingDescription = message.nowplayingDescription.replace("%radio.station.owner%", radio.station.owner); + if(radio.station.name != radio.station.owner){ + message.nowplayingDescription = message.nowplayingDescription.replace("%radio.station.owner%", radio.station.owner); + } else { + message.nowplayingDescription = message.nowplayingDescription.replace("%radio.station.owner%" + "\n", ""); + } message.nowplayingDescription = message.nowplayingDescription.replace("%client.funcs.msToTime(completed)%", ""); message.nowplayingDescription = message.nowplayingDescription.replace("Owner: ", ""); message.nowplayingDescription = message.nowplayingDescription.replace("**", ""); From 892c5f99023c39688b461bd564d84acc00725a3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sun, 12 Sep 2021 17:09:32 +0300 Subject: [PATCH 041/105] Update Streamer class --- src/client/classes/Streamer.js | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/client/classes/Streamer.js b/src/client/classes/Streamer.js index ee8df57..a796e76 100644 --- a/src/client/classes/Streamer.js +++ b/src/client/classes/Streamer.js @@ -6,21 +6,33 @@ const { module.exports = class { constructor() { this.map = new Map(); + this.mode = "auto"; this.stations = null; this.logger = require("../funcs/logger.js"); } init(client){ - if(!client.stations) return; + if(!client.config.streamerMode) return; - client.stations.forEach(station => { - let audioPlayer = this.map.get(station.name); - if(!audioPlayer) { - audioPlayer = createAudioPlayer(); - this.map.set(station.name, audioPlayer); - } - this.play(station); - }); + switch(client.config.streamerMode){ + case "manual": + this.mode = "manual"; + default: + this.mode = "auto"; + } + + if(this.mode == "auto"){ + if(!client.stations) return; + + client.stations.forEach(station => { + let audioPlayer = this.map.get(station.name); + if(!audioPlayer) { + audioPlayer = createAudioPlayer(); + this.map.set(station.name, audioPlayer); + } + this.play(station); + }); + } } refresh(client){ From b08de94c64955183d8ea8aeadb9317a00d926bfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sun, 12 Sep 2021 17:37:43 +0300 Subject: [PATCH 042/105] Update functions --- src/client/funcs/checkFetchStatus.js | 2 +- src/client/funcs/isDev.js | 2 +- src/client/funcs/listStations.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/funcs/checkFetchStatus.js b/src/client/funcs/checkFetchStatus.js index 4774d77..cd45e30 100644 --- a/src/client/funcs/checkFetchStatus.js +++ b/src/client/funcs/checkFetchStatus.js @@ -1,4 +1,4 @@ -module.exports = function (response) { +module.exports = function checkFetchStatus(response) { if (response.ok) { // res.status >= 200 && res.status < 300 return response; } else { diff --git a/src/client/funcs/isDev.js b/src/client/funcs/isDev.js index 3992c1e..8be3ac9 100644 --- a/src/client/funcs/isDev.js +++ b/src/client/funcs/isDev.js @@ -1,4 +1,4 @@ -module.exports = function (devList, authorID){ +module.exports = function isDev(devList, authorID){ let response = false; Object.keys(devList).forEach(function(oneDev) { let devID = devList[oneDev]; diff --git a/src/client/funcs/listStations.js b/src/client/funcs/listStations.js index d0cb036..2dd73db 100644 --- a/src/client/funcs/listStations.js +++ b/src/client/funcs/listStations.js @@ -1,6 +1,6 @@ import Discord from "discord.js"; -module.exports = function (client, interaction){ +module.exports = function listStations(client, interaction){ let stations = new Array(); let options = new Array(); From 752bd07c5db1003d9c4d4924cf9cb43488b0138e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sun, 12 Sep 2021 17:38:52 +0300 Subject: [PATCH 043/105] client.config.maintenance to client.config.maintenanceMode --- src/Client.ts | 2 +- src/client/commands/list.js | 2 +- src/client/commands/play.js | 2 +- src/client/funcs/check.js | 4 ++-- src/config.js | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Client.ts b/src/Client.ts index af0c835..aba71a5 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -57,7 +57,7 @@ class RadioClient extends Client { this.funcs.logger("Bot", "Starting"); this.funcs.logger("Maintenance Mode", "Enabled"); - this.config.maintenance = true; + this.config.maintenanceMode = true; const commandFiles = fs.readdirSync(path.join("./src/client/commands")).filter(f => f.endsWith(".js")); for (const file of commandFiles) { diff --git a/src/client/commands/list.js b/src/client/commands/list.js index 59772f0..70ba290 100644 --- a/src/client/commands/list.js +++ b/src/client/commands/list.js @@ -17,7 +17,7 @@ module.exports = { const radio = client.radio.get(interaction.guild.id); - if(radio && !client.config.maintenance){ + if(radio && !client.config.maintenanceMode){ client.funcs.listStations(client, interaction); } else { let stations = `${client.stations.map(s => `**#** ${s.name}`).join('\n')}` diff --git a/src/client/commands/play.js b/src/client/commands/play.js index 3184e8f..2de1239 100644 --- a/src/client/commands/play.js +++ b/src/client/commands/play.js @@ -14,7 +14,7 @@ module.exports = { async execute(interaction, client) { let message = {}; - if(client.config.maintenance){ + if(client.config.maintenanceMode){ interaction.reply({ content: client.messageEmojis["error"] + client.messages.maintenance, ephemeral: true diff --git a/src/client/funcs/check.js b/src/client/funcs/check.js index e164cbb..4a5a216 100644 --- a/src/client/funcs/check.js +++ b/src/client/funcs/check.js @@ -1,8 +1,8 @@ -module.exports = function (client, interaction, command) { +module.exports = function check(client, interaction, command) { let message = {}; const radio = client.radio.get(interaction.guild.id); const permissions = interaction.channel.permissionsFor(interaction.user); - if(client.config.maintenance){ + if(client.config.maintenanceMode){ interaction.reply({ content: client.messageEmojis["error"] + client.messages.maintenance, ephemeral: true diff --git a/src/config.js b/src/config.js index dd005d8..0b1eca1 100644 --- a/src/config.js +++ b/src/config.js @@ -22,6 +22,6 @@ module.exports = { //Settings version: process.env.RADIOX_VERSION || process.env.npm_package_version, debug: process.env.DEBUG_MODE || false, - maintenance: false, + maintenanceMode: false, streamerMode: process.env.STREAMER_MODE || "auto" } From 3ed49f88ab3fd2ed843352d442fa9ea27d159b6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sun, 12 Sep 2021 17:39:23 +0300 Subject: [PATCH 044/105] Update Streamer class --- src/client/classes/Streamer.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/client/classes/Streamer.js b/src/client/classes/Streamer.js index a796e76..d22cb49 100644 --- a/src/client/classes/Streamer.js +++ b/src/client/classes/Streamer.js @@ -6,8 +6,7 @@ const { module.exports = class { constructor() { this.map = new Map(); - this.mode = "auto"; - this.stations = null; + this.mode = null; this.logger = require("../funcs/logger.js"); } @@ -17,6 +16,7 @@ module.exports = class { switch(client.config.streamerMode){ case "manual": this.mode = "manual"; + break; default: this.mode = "auto"; } @@ -25,11 +25,6 @@ module.exports = class { if(!client.stations) return; client.stations.forEach(station => { - let audioPlayer = this.map.get(station.name); - if(!audioPlayer) { - audioPlayer = createAudioPlayer(); - this.map.set(station.name, audioPlayer); - } this.play(station); }); } @@ -46,7 +41,11 @@ module.exports = class { } play(station) { - const audioPlayer = this.map.get(station.name); + let audioPlayer = this.map.get(station.name); + if(!audioPlayer) { + audioPlayer = createAudioPlayer(); + this.map.set(station.name, audioPlayer); + } const url = station.stream[station.stream.default]; const resource = createAudioResource(url); audioPlayer.play(resource); From 88fdad4ab932fd8f1a76e84c50c53ea8ef9a31f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sun, 12 Sep 2021 17:39:38 +0300 Subject: [PATCH 045/105] Update maintenance command --- src/client/commands/maintenance.js | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/client/commands/maintenance.js b/src/client/commands/maintenance.js index de6d185..013f416 100644 --- a/src/client/commands/maintenance.js +++ b/src/client/commands/maintenance.js @@ -59,6 +59,18 @@ module.exports = { label: "Disable Maintenance Mode", description: "", value: "9" + }, + { + emoji: "💤", + label: "Streamer Mode – Manual", + description: "", + value: "10" + }, + { + emoji: "📡", + label: "Streamer Mode – Auto", + description: "", + value: "11" } ); @@ -142,6 +154,36 @@ module.exports = { client.user.setStatus('online'); client.funcs.logger("Maintenance Mode", "Disabled"); client.config.maintenance = false; + break; + case "10": + client.config.maintenance = true; + client.user.setStatus('idle'); + client.funcs.saveRadios(client); + + client.config.streamerMode = "manual"; + client.streamer.leave(client); + client.streamer.init(client); + + let guilds = await client.guilds.fetch(); + client.funcs.restoreRadios(client, guilds); + client.user.setStatus('online'); + client.config.maintenance = false; + + break; + case "11": + client.config.maintenance = true; + client.user.setStatus('idle'); + client.funcs.saveRadios(client); + + client.config.streamerMode = "auto"; + client.streamer.leave(client); + client.streamer.init(client); + + let guilds = await client.guilds.fetch(); + client.funcs.restoreRadios(client, guilds); + client.user.setStatus('online'); + client.config.maintenance = false; + break; default: From a20e7a1c8e19a09a123bf1912335397bfce206c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sun, 12 Sep 2021 17:49:07 +0300 Subject: [PATCH 046/105] Update ready.js --- src/client/events/ready.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/events/ready.js b/src/client/events/ready.js index 403b725..6cbd876 100644 --- a/src/client/events/ready.js +++ b/src/client/events/ready.js @@ -108,7 +108,7 @@ module.exports = { if(client.stations) { /*MAINTENANCE MODE*/ client.funcs.logger("Maintenance Mode", "Disabled"); - client.config.maintenance = false; + client.config.maintenanceMode = false; } }, 10000); From 4b0efe74918f260725395f1973e5129c2d508f0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sun, 12 Sep 2021 17:49:21 +0300 Subject: [PATCH 047/105] Update maintenance command --- src/client/commands/maintenance.js | 36 +++++++++++++++++------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/client/commands/maintenance.js b/src/client/commands/maintenance.js index 013f416..966a517 100644 --- a/src/client/commands/maintenance.js +++ b/src/client/commands/maintenance.js @@ -1,4 +1,5 @@ import Discord from "discord.js"; +import Streamer from "../classes/Streamer.js"; const _importDynamic = new Function('modulePath', 'return import(modulePath)'); const fetch = (...args) => _importDynamic('node-fetch').then(({default: fetch}) => fetch(...args)); @@ -103,32 +104,33 @@ module.exports = { ephemeral: true }); + let guilds = await client.guilds.fetch(); + switch(action){ case "0": - client.config.maintenance = true; + client.config.maintenanceMode = true; process.emit('SIGINT'); break; case "4": - client.config.maintenance = true; + client.config.maintenanceMode = true; client.user.setStatus('idle'); client.funcs.saveRadios(client); client.user.setStatus('online'); - client.config.maintenance = false; + client.config.maintenanceMode = false; break; case "5": - client.config.maintenance = true; + client.config.maintenanceMode = true; client.user.setStatus('idle'); - let guilds = await client.guilds.fetch(); client.funcs.restoreRadios(client, guilds); client.user.setStatus('online'); - client.config.maintenance = false; + client.config.maintenanceMode = false; break; case "6": - client.config.maintenance = true; + client.config.maintenanceMode = true; client.user.setStatus('idle'); require(`../commands.js`).execute(client); client.user.setStatus('online'); - client.config.maintenance = false; + client.config.maintenanceMode = false; break; case "7": try { @@ -148,41 +150,43 @@ module.exports = { case "8": client.user.setStatus('dnd'); client.funcs.logger("Maintenance Mode", "Enabled"); - client.config.maintenance = true; + client.config.maintenanceMode = true; break; case "9": client.user.setStatus('online'); client.funcs.logger("Maintenance Mode", "Disabled"); - client.config.maintenance = false; + client.config.maintenanceMode = false; break; case "10": - client.config.maintenance = true; + client.config.maintenanceMode = true; client.user.setStatus('idle'); client.funcs.saveRadios(client); client.config.streamerMode = "manual"; client.streamer.leave(client); + + client.streamer = new Streamer(); client.streamer.init(client); - let guilds = await client.guilds.fetch(); client.funcs.restoreRadios(client, guilds); client.user.setStatus('online'); - client.config.maintenance = false; + client.config.maintenanceMode = false; break; case "11": - client.config.maintenance = true; + client.config.maintenanceMode = true; client.user.setStatus('idle'); client.funcs.saveRadios(client); client.config.streamerMode = "auto"; client.streamer.leave(client); + + client.streamer = new Streamer(); client.streamer.init(client); - let guilds = await client.guilds.fetch(); client.funcs.restoreRadios(client, guilds); client.user.setStatus('online'); - client.config.maintenance = false; + client.config.maintenanceMode = false; break; default: From 720d356d1f19b5442d983f708b145a59380858ca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Sep 2021 08:03:00 +0000 Subject: [PATCH 048/105] Bump @typescript-eslint/parser from 4.31.0 to 4.31.1 Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.31.0 to 4.31.1. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.31.1/packages/parser) --- updated-dependencies: - dependency-name: "@typescript-eslint/parser" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package-lock.json | 143 +++++++++++++++++++++++++++++++++++++++++----- package.json | 2 +- 2 files changed, 131 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index 22f23b3..403f343 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,7 +24,7 @@ "@types/node": "^16.9.1", "@types/ws": "^7.4.7", "@typescript-eslint/eslint-plugin": "^4.31.0", - "@typescript-eslint/parser": "^4.31.0", + "@typescript-eslint/parser": "^4.31.1", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", @@ -568,14 +568,14 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "4.31.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.31.0.tgz", - "integrity": "sha512-oWbzvPh5amMuTmKaf1wp0ySxPt2ZXHnFQBN2Szu1O//7LmOvgaKTCIDNLK2NvzpmVd5A2M/1j/rujBqO37hj3w==", + "version": "4.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.31.1.tgz", + "integrity": "sha512-dnVZDB6FhpIby6yVbHkwTKkn2ypjVIfAR9nh+kYsA/ZL0JlTsd22BiDjouotisY3Irmd3OW1qlk9EI5R8GrvRQ==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "4.31.0", - "@typescript-eslint/types": "4.31.0", - "@typescript-eslint/typescript-estree": "4.31.0", + "@typescript-eslint/scope-manager": "4.31.1", + "@typescript-eslint/types": "4.31.1", + "@typescript-eslint/typescript-estree": "4.31.1", "debug": "^4.3.1" }, "engines": { @@ -594,6 +594,80 @@ } } }, + "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager": { + "version": "4.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.31.1.tgz", + "integrity": "sha512-N1Uhn6SqNtU2XpFSkD4oA+F0PfKdWHyr4bTX0xTj8NRx1314gBDRL1LUuZd5+L3oP+wo6hCbZpaa1in6SwMcVQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "4.31.1", + "@typescript-eslint/visitor-keys": "4.31.1" + }, + "engines": { + "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/types": { + "version": "4.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.31.1.tgz", + "integrity": "sha512-kixltt51ZJGKENNW88IY5MYqTBA8FR0Md8QdGbJD2pKZ+D5IvxjTYDNtJPDxFBiXmka2aJsITdB1BtO1fsgmsQ==", + "dev": true, + "engines": { + "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/typescript-estree": { + "version": "4.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.31.1.tgz", + "integrity": "sha512-EGHkbsUvjFrvRnusk6yFGqrqMBTue5E5ROnS5puj3laGQPasVUgwhrxfcgkdHNFECHAewpvELE1Gjv0XO3mdWg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "4.31.1", + "@typescript-eslint/visitor-keys": "4.31.1", + "debug": "^4.3.1", + "globby": "^11.0.3", + "is-glob": "^4.0.1", + "semver": "^7.3.5", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/visitor-keys": { + "version": "4.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.31.1.tgz", + "integrity": "sha512-PCncP8hEqKw6SOJY+3St4LVtoZpPPn+Zlpm7KW5xnviMhdqcsBty4Lsg4J/VECpJjw1CkROaZhH4B8M1OfnXTQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "4.31.1", + "eslint-visitor-keys": "^2.0.0" + }, + "engines": { + "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, "node_modules/@typescript-eslint/scope-manager": { "version": "4.31.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.31.0.tgz", @@ -4411,15 +4485,58 @@ } }, "@typescript-eslint/parser": { - "version": "4.31.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.31.0.tgz", - "integrity": "sha512-oWbzvPh5amMuTmKaf1wp0ySxPt2ZXHnFQBN2Szu1O//7LmOvgaKTCIDNLK2NvzpmVd5A2M/1j/rujBqO37hj3w==", + "version": "4.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.31.1.tgz", + "integrity": "sha512-dnVZDB6FhpIby6yVbHkwTKkn2ypjVIfAR9nh+kYsA/ZL0JlTsd22BiDjouotisY3Irmd3OW1qlk9EI5R8GrvRQ==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "4.31.0", - "@typescript-eslint/types": "4.31.0", - "@typescript-eslint/typescript-estree": "4.31.0", + "@typescript-eslint/scope-manager": "4.31.1", + "@typescript-eslint/types": "4.31.1", + "@typescript-eslint/typescript-estree": "4.31.1", "debug": "^4.3.1" + }, + "dependencies": { + "@typescript-eslint/scope-manager": { + "version": "4.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.31.1.tgz", + "integrity": "sha512-N1Uhn6SqNtU2XpFSkD4oA+F0PfKdWHyr4bTX0xTj8NRx1314gBDRL1LUuZd5+L3oP+wo6hCbZpaa1in6SwMcVQ==", + "dev": true, + "requires": { + "@typescript-eslint/types": "4.31.1", + "@typescript-eslint/visitor-keys": "4.31.1" + } + }, + "@typescript-eslint/types": { + "version": "4.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.31.1.tgz", + "integrity": "sha512-kixltt51ZJGKENNW88IY5MYqTBA8FR0Md8QdGbJD2pKZ+D5IvxjTYDNtJPDxFBiXmka2aJsITdB1BtO1fsgmsQ==", + "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "4.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.31.1.tgz", + "integrity": "sha512-EGHkbsUvjFrvRnusk6yFGqrqMBTue5E5ROnS5puj3laGQPasVUgwhrxfcgkdHNFECHAewpvELE1Gjv0XO3mdWg==", + "dev": true, + "requires": { + "@typescript-eslint/types": "4.31.1", + "@typescript-eslint/visitor-keys": "4.31.1", + "debug": "^4.3.1", + "globby": "^11.0.3", + "is-glob": "^4.0.1", + "semver": "^7.3.5", + "tsutils": "^3.21.0" + } + }, + "@typescript-eslint/visitor-keys": { + "version": "4.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.31.1.tgz", + "integrity": "sha512-PCncP8hEqKw6SOJY+3St4LVtoZpPPn+Zlpm7KW5xnviMhdqcsBty4Lsg4J/VECpJjw1CkROaZhH4B8M1OfnXTQ==", + "dev": true, + "requires": { + "@typescript-eslint/types": "4.31.1", + "eslint-visitor-keys": "^2.0.0" + } + } } }, "@typescript-eslint/scope-manager": { diff --git a/package.json b/package.json index cbd39c2..2544abb 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "@types/node": "^16.9.1", "@types/ws": "^7.4.7", "@typescript-eslint/eslint-plugin": "^4.31.0", - "@typescript-eslint/parser": "^4.31.0", + "@typescript-eslint/parser": "^4.31.1", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", From d03b8cdb1d8b79408f7896eb7c4a0c59bd6da703 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Sep 2021 08:42:36 +0000 Subject: [PATCH 049/105] Bump @typescript-eslint/eslint-plugin from 4.31.0 to 4.31.1 Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.31.0 to 4.31.1. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.31.1/packages/eslint-plugin) --- updated-dependencies: - dependency-name: "@typescript-eslint/eslint-plugin" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package-lock.json | 205 ++++++++++------------------------------------ package.json | 2 +- 2 files changed, 45 insertions(+), 162 deletions(-) diff --git a/package-lock.json b/package-lock.json index 403f343..c983b8c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "devDependencies": { "@types/node": "^16.9.1", "@types/ws": "^7.4.7", - "@typescript-eslint/eslint-plugin": "^4.31.0", + "@typescript-eslint/eslint-plugin": "^4.31.1", "@typescript-eslint/parser": "^4.31.1", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", @@ -513,13 +513,13 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "4.31.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.31.0.tgz", - "integrity": "sha512-iPKZTZNavAlOhfF4gymiSuUkgLne/nh5Oz2/mdiUmuZVD42m9PapnCnzjxuDsnpnbH3wT5s2D8bw6S39TC6GNw==", + "version": "4.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.31.1.tgz", + "integrity": "sha512-UDqhWmd5i0TvPLmbK5xY3UZB0zEGseF+DHPghZ37Sb83Qd3p8ujhvAtkU4OF46Ka5Pm5kWvFIx0cCTBFKo0alA==", "dev": true, "dependencies": { - "@typescript-eslint/experimental-utils": "4.31.0", - "@typescript-eslint/scope-manager": "4.31.0", + "@typescript-eslint/experimental-utils": "4.31.1", + "@typescript-eslint/scope-manager": "4.31.1", "debug": "^4.3.1", "functional-red-black-tree": "^1.0.1", "regexpp": "^3.1.0", @@ -544,15 +544,15 @@ } }, "node_modules/@typescript-eslint/experimental-utils": { - "version": "4.31.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.31.0.tgz", - "integrity": "sha512-Hld+EQiKLMppgKKkdUsLeVIeEOrwKc2G983NmznY/r5/ZtZCDvIOXnXtwqJIgYz/ymsy7n7RGvMyrzf1WaSQrw==", + "version": "4.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.31.1.tgz", + "integrity": "sha512-NtoPsqmcSsWty0mcL5nTZXMf7Ei0Xr2MT8jWjXMVgRK0/1qeQ2jZzLFUh4QtyJ4+/lPUyMw5cSfeeME+Zrtp9Q==", "dev": true, "dependencies": { "@types/json-schema": "^7.0.7", - "@typescript-eslint/scope-manager": "4.31.0", - "@typescript-eslint/types": "4.31.0", - "@typescript-eslint/typescript-estree": "4.31.0", + "@typescript-eslint/scope-manager": "4.31.1", + "@typescript-eslint/types": "4.31.1", + "@typescript-eslint/typescript-estree": "4.31.1", "eslint-scope": "^5.1.1", "eslint-utils": "^3.0.0" }, @@ -594,7 +594,7 @@ } } }, - "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager": { + "node_modules/@typescript-eslint/scope-manager": { "version": "4.31.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.31.1.tgz", "integrity": "sha512-N1Uhn6SqNtU2XpFSkD4oA+F0PfKdWHyr4bTX0xTj8NRx1314gBDRL1LUuZd5+L3oP+wo6hCbZpaa1in6SwMcVQ==", @@ -611,7 +611,7 @@ "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/types": { + "node_modules/@typescript-eslint/types": { "version": "4.31.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.31.1.tgz", "integrity": "sha512-kixltt51ZJGKENNW88IY5MYqTBA8FR0Md8QdGbJD2pKZ+D5IvxjTYDNtJPDxFBiXmka2aJsITdB1BtO1fsgmsQ==", @@ -624,7 +624,7 @@ "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/typescript-estree": { + "node_modules/@typescript-eslint/typescript-estree": { "version": "4.31.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.31.1.tgz", "integrity": "sha512-EGHkbsUvjFrvRnusk6yFGqrqMBTue5E5ROnS5puj3laGQPasVUgwhrxfcgkdHNFECHAewpvELE1Gjv0XO3mdWg==", @@ -651,7 +651,7 @@ } } }, - "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/visitor-keys": { + "node_modules/@typescript-eslint/visitor-keys": { "version": "4.31.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.31.1.tgz", "integrity": "sha512-PCncP8hEqKw6SOJY+3St4LVtoZpPPn+Zlpm7KW5xnviMhdqcsBty4Lsg4J/VECpJjw1CkROaZhH4B8M1OfnXTQ==", @@ -668,80 +668,6 @@ "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/@typescript-eslint/scope-manager": { - "version": "4.31.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.31.0.tgz", - "integrity": "sha512-LJ+xtl34W76JMRLjbaQorhR0hfRAlp3Lscdiz9NeI/8i+q0hdBZ7BsiYieLoYWqy+AnRigaD3hUwPFugSzdocg==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "4.31.0", - "@typescript-eslint/visitor-keys": "4.31.0" - }, - "engines": { - "node": "^8.10.0 || ^10.13.0 || >=11.10.1" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/types": { - "version": "4.31.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.31.0.tgz", - "integrity": "sha512-9XR5q9mk7DCXgXLS7REIVs+BaAswfdHhx91XqlJklmqWpTALGjygWVIb/UnLh4NWhfwhR5wNe1yTyCInxVhLqQ==", - "dev": true, - "engines": { - "node": "^8.10.0 || ^10.13.0 || >=11.10.1" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/typescript-estree": { - "version": "4.31.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.31.0.tgz", - "integrity": "sha512-QHl2014t3ptg+xpmOSSPn5hm4mY8D4s97ftzyk9BZ8RxYQ3j73XcwuijnJ9cMa6DO4aLXeo8XS3z1omT9LA/Eg==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "4.31.0", - "@typescript-eslint/visitor-keys": "4.31.0", - "debug": "^4.3.1", - "globby": "^11.0.3", - "is-glob": "^4.0.1", - "semver": "^7.3.5", - "tsutils": "^3.21.0" - }, - "engines": { - "node": "^10.12.0 || >=12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/visitor-keys": { - "version": "4.31.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.31.0.tgz", - "integrity": "sha512-HUcRp2a9I+P21+O21yu3ezv3GEPGjyGiXoEUQwZXjR8UxRApGeLyWH4ZIIUSalE28aG4YsV6GjtaAVB3QKOu0w==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "4.31.0", - "eslint-visitor-keys": "^2.0.0" - }, - "engines": { - "node": "^8.10.0 || ^10.13.0 || >=11.10.1" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, "node_modules/abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -4456,13 +4382,13 @@ } }, "@typescript-eslint/eslint-plugin": { - "version": "4.31.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.31.0.tgz", - "integrity": "sha512-iPKZTZNavAlOhfF4gymiSuUkgLne/nh5Oz2/mdiUmuZVD42m9PapnCnzjxuDsnpnbH3wT5s2D8bw6S39TC6GNw==", + "version": "4.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.31.1.tgz", + "integrity": "sha512-UDqhWmd5i0TvPLmbK5xY3UZB0zEGseF+DHPghZ37Sb83Qd3p8ujhvAtkU4OF46Ka5Pm5kWvFIx0cCTBFKo0alA==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "4.31.0", - "@typescript-eslint/scope-manager": "4.31.0", + "@typescript-eslint/experimental-utils": "4.31.1", + "@typescript-eslint/scope-manager": "4.31.1", "debug": "^4.3.1", "functional-red-black-tree": "^1.0.1", "regexpp": "^3.1.0", @@ -4471,15 +4397,15 @@ } }, "@typescript-eslint/experimental-utils": { - "version": "4.31.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.31.0.tgz", - "integrity": "sha512-Hld+EQiKLMppgKKkdUsLeVIeEOrwKc2G983NmznY/r5/ZtZCDvIOXnXtwqJIgYz/ymsy7n7RGvMyrzf1WaSQrw==", + "version": "4.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.31.1.tgz", + "integrity": "sha512-NtoPsqmcSsWty0mcL5nTZXMf7Ei0Xr2MT8jWjXMVgRK0/1qeQ2jZzLFUh4QtyJ4+/lPUyMw5cSfeeME+Zrtp9Q==", "dev": true, "requires": { "@types/json-schema": "^7.0.7", - "@typescript-eslint/scope-manager": "4.31.0", - "@typescript-eslint/types": "4.31.0", - "@typescript-eslint/typescript-estree": "4.31.0", + "@typescript-eslint/scope-manager": "4.31.1", + "@typescript-eslint/types": "4.31.1", + "@typescript-eslint/typescript-estree": "4.31.1", "eslint-scope": "^5.1.1", "eslint-utils": "^3.0.0" } @@ -4494,75 +4420,32 @@ "@typescript-eslint/types": "4.31.1", "@typescript-eslint/typescript-estree": "4.31.1", "debug": "^4.3.1" - }, - "dependencies": { - "@typescript-eslint/scope-manager": { - "version": "4.31.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.31.1.tgz", - "integrity": "sha512-N1Uhn6SqNtU2XpFSkD4oA+F0PfKdWHyr4bTX0xTj8NRx1314gBDRL1LUuZd5+L3oP+wo6hCbZpaa1in6SwMcVQ==", - "dev": true, - "requires": { - "@typescript-eslint/types": "4.31.1", - "@typescript-eslint/visitor-keys": "4.31.1" - } - }, - "@typescript-eslint/types": { - "version": "4.31.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.31.1.tgz", - "integrity": "sha512-kixltt51ZJGKENNW88IY5MYqTBA8FR0Md8QdGbJD2pKZ+D5IvxjTYDNtJPDxFBiXmka2aJsITdB1BtO1fsgmsQ==", - "dev": true - }, - "@typescript-eslint/typescript-estree": { - "version": "4.31.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.31.1.tgz", - "integrity": "sha512-EGHkbsUvjFrvRnusk6yFGqrqMBTue5E5ROnS5puj3laGQPasVUgwhrxfcgkdHNFECHAewpvELE1Gjv0XO3mdWg==", - "dev": true, - "requires": { - "@typescript-eslint/types": "4.31.1", - "@typescript-eslint/visitor-keys": "4.31.1", - "debug": "^4.3.1", - "globby": "^11.0.3", - "is-glob": "^4.0.1", - "semver": "^7.3.5", - "tsutils": "^3.21.0" - } - }, - "@typescript-eslint/visitor-keys": { - "version": "4.31.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.31.1.tgz", - "integrity": "sha512-PCncP8hEqKw6SOJY+3St4LVtoZpPPn+Zlpm7KW5xnviMhdqcsBty4Lsg4J/VECpJjw1CkROaZhH4B8M1OfnXTQ==", - "dev": true, - "requires": { - "@typescript-eslint/types": "4.31.1", - "eslint-visitor-keys": "^2.0.0" - } - } } }, "@typescript-eslint/scope-manager": { - "version": "4.31.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.31.0.tgz", - "integrity": "sha512-LJ+xtl34W76JMRLjbaQorhR0hfRAlp3Lscdiz9NeI/8i+q0hdBZ7BsiYieLoYWqy+AnRigaD3hUwPFugSzdocg==", + "version": "4.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.31.1.tgz", + "integrity": "sha512-N1Uhn6SqNtU2XpFSkD4oA+F0PfKdWHyr4bTX0xTj8NRx1314gBDRL1LUuZd5+L3oP+wo6hCbZpaa1in6SwMcVQ==", "dev": true, "requires": { - "@typescript-eslint/types": "4.31.0", - "@typescript-eslint/visitor-keys": "4.31.0" + "@typescript-eslint/types": "4.31.1", + "@typescript-eslint/visitor-keys": "4.31.1" } }, "@typescript-eslint/types": { - "version": "4.31.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.31.0.tgz", - "integrity": "sha512-9XR5q9mk7DCXgXLS7REIVs+BaAswfdHhx91XqlJklmqWpTALGjygWVIb/UnLh4NWhfwhR5wNe1yTyCInxVhLqQ==", + "version": "4.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.31.1.tgz", + "integrity": "sha512-kixltt51ZJGKENNW88IY5MYqTBA8FR0Md8QdGbJD2pKZ+D5IvxjTYDNtJPDxFBiXmka2aJsITdB1BtO1fsgmsQ==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "4.31.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.31.0.tgz", - "integrity": "sha512-QHl2014t3ptg+xpmOSSPn5hm4mY8D4s97ftzyk9BZ8RxYQ3j73XcwuijnJ9cMa6DO4aLXeo8XS3z1omT9LA/Eg==", + "version": "4.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.31.1.tgz", + "integrity": "sha512-EGHkbsUvjFrvRnusk6yFGqrqMBTue5E5ROnS5puj3laGQPasVUgwhrxfcgkdHNFECHAewpvELE1Gjv0XO3mdWg==", "dev": true, "requires": { - "@typescript-eslint/types": "4.31.0", - "@typescript-eslint/visitor-keys": "4.31.0", + "@typescript-eslint/types": "4.31.1", + "@typescript-eslint/visitor-keys": "4.31.1", "debug": "^4.3.1", "globby": "^11.0.3", "is-glob": "^4.0.1", @@ -4571,12 +4454,12 @@ } }, "@typescript-eslint/visitor-keys": { - "version": "4.31.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.31.0.tgz", - "integrity": "sha512-HUcRp2a9I+P21+O21yu3ezv3GEPGjyGiXoEUQwZXjR8UxRApGeLyWH4ZIIUSalE28aG4YsV6GjtaAVB3QKOu0w==", + "version": "4.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.31.1.tgz", + "integrity": "sha512-PCncP8hEqKw6SOJY+3St4LVtoZpPPn+Zlpm7KW5xnviMhdqcsBty4Lsg4J/VECpJjw1CkROaZhH4B8M1OfnXTQ==", "dev": true, "requires": { - "@typescript-eslint/types": "4.31.0", + "@typescript-eslint/types": "4.31.1", "eslint-visitor-keys": "^2.0.0" } }, diff --git a/package.json b/package.json index 2544abb..8571515 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "devDependencies": { "@types/node": "^16.9.1", "@types/ws": "^7.4.7", - "@typescript-eslint/eslint-plugin": "^4.31.0", + "@typescript-eslint/eslint-plugin": "^4.31.1", "@typescript-eslint/parser": "^4.31.1", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", From b76b7a107c570d76f7cb9877d6ae22141f6530eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Tue, 14 Sep 2021 14:52:04 +0300 Subject: [PATCH 050/105] Update maintenance command --- src/client/commands/maintenance.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/commands/maintenance.js b/src/client/commands/maintenance.js index 966a517..b9c5793 100644 --- a/src/client/commands/maintenance.js +++ b/src/client/commands/maintenance.js @@ -162,9 +162,9 @@ module.exports = { client.user.setStatus('idle'); client.funcs.saveRadios(client); - client.config.streamerMode = "manual"; client.streamer.leave(client); + client.config.streamerMode = "manual"; client.streamer = new Streamer(); client.streamer.init(client); @@ -178,9 +178,9 @@ module.exports = { client.user.setStatus('idle'); client.funcs.saveRadios(client); - client.config.streamerMode = "auto"; client.streamer.leave(client); + client.config.streamerMode = "auto"; client.streamer = new Streamer(); client.streamer.init(client); From 81a9d7be7c0b5edca7e548d63891265fb27bb14a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Tue, 14 Sep 2021 17:12:18 +0300 Subject: [PATCH 051/105] Update Datastore class --- src/client/classes/Datastore.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/client/classes/Datastore.js b/src/client/classes/Datastore.js index 89c2751..b18c225 100644 --- a/src/client/classes/Datastore.js +++ b/src/client/classes/Datastore.js @@ -67,6 +67,7 @@ module.exports = class { checkEntry(id){ + this.loadEntry(id); if(!this.map.has(id)){ this.createEntry(id); //this.showEntry(this.getEntry(id)); @@ -85,6 +86,11 @@ module.exports = class { this.saveEntry(id, newData); } + loadEntry(id){ + const json = require(`../../../datastore/` + id + '.json'); + this.map.set(id, json); + } + getEntry(id){ return this.map.get(id); } From 930d481fcf8488f45eeb7a3f738ef0e9f407608f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Tue, 14 Sep 2021 17:12:30 +0300 Subject: [PATCH 052/105] Update Streamer class --- src/client/classes/Streamer.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/client/classes/Streamer.js b/src/client/classes/Streamer.js index d22cb49..a841ad7 100644 --- a/src/client/classes/Streamer.js +++ b/src/client/classes/Streamer.js @@ -69,7 +69,10 @@ module.exports = class { stop(station){ let audioPlayer = this.map.get(station.name); - audioPlayer?.stop(); + if(audioPlayer){ + this.logger('Streamer', station.name + " / " + "Stop"); + audioPlayer.stop(); + } this.map.delete(station.name); } From 2892913caa55dbdeb22b7a755aa6af706fedee2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Tue, 14 Sep 2021 17:12:47 +0300 Subject: [PATCH 053/105] Update maintenance command --- src/client/commands/maintenance.js | 44 ++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/src/client/commands/maintenance.js b/src/client/commands/maintenance.js index b9c5793..d161b61 100644 --- a/src/client/commands/maintenance.js +++ b/src/client/commands/maintenance.js @@ -158,35 +158,51 @@ module.exports = { client.config.maintenanceMode = false; break; case "10": + client.config.streamerMode = "manual"; client.config.maintenanceMode = true; + client.user.setStatus('idle'); client.funcs.saveRadios(client); - client.streamer.leave(client); + setInterval(() => { + if(client.radio.size == 0 && client.config.streamerMode == "manual" && client.config.maintenanceMode){ + client.streamer.leave(client); + client.streamer = new Streamer(); + client.streamer.init(client); - client.config.streamerMode = "manual"; - client.streamer = new Streamer(); - client.streamer.init(client); + client.funcs.restoreRadios(client, guilds); + client.user.setStatus('online'); + client.config.maintenanceMode = false; + } - client.funcs.restoreRadios(client, guilds); - client.user.setStatus('online'); - client.config.maintenanceMode = false; + if(!client.config.maintenanceMode){ + clearInterval(); + } + }, 500); break; case "11": + client.config.streamerMode = "auto"; client.config.maintenanceMode = true; + client.user.setStatus('idle'); client.funcs.saveRadios(client); - client.streamer.leave(client); + setInterval(() => { + if(client.radio.size == 0 && client.config.streamerMode == "auto" && client.config.maintenanceMode){ + client.streamer.leave(client); + client.streamer = new Streamer(); + client.streamer.init(client); - client.config.streamerMode = "auto"; - client.streamer = new Streamer(); - client.streamer.init(client); + client.funcs.restoreRadios(client, guilds); + client.user.setStatus('online'); + client.config.maintenanceMode = false; + } - client.funcs.restoreRadios(client, guilds); - client.user.setStatus('online'); - client.config.maintenanceMode = false; + if(!client.config.maintenanceMode){ + clearInterval(); + } + }, 500); break; default: From a43a788e15ae49497b40a61f43dfbe0e9a9e3e78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Tue, 14 Sep 2021 17:13:17 +0300 Subject: [PATCH 054/105] Update play command --- src/client/commands/play.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/client/commands/play.js b/src/client/commands/play.js index 2de1239..52a5a41 100644 --- a/src/client/commands/play.js +++ b/src/client/commands/play.js @@ -128,14 +128,6 @@ module.exports = { client.funcs.play(client, interaction, interaction.guild, station); client.datastore.checkEntry(interaction.guild.id); - construct.currentGuild = client.datastore.getEntry(interaction.guild.id); - - if (!construct.currentGuild.statistics[construct.station.name]) { - construct.currentGuild.statistics[construct.station.name] = {}; - construct.currentGuild.statistics[construct.station.name].time = 0; - construct.currentGuild.statistics[construct.station.name].used = 0; - client.datastore.updateEntry(interaction.guild, construct.currentGuild); - } } catch (error) { console.log(error); client.radio.delete(interaction.guild.id); From 24478b6320d03efce331af17d5b9bb7ac2658b53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Tue, 14 Sep 2021 17:13:37 +0300 Subject: [PATCH 055/105] Update saveRadios function --- src/client/funcs/saveRadios.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/client/funcs/saveRadios.js b/src/client/funcs/saveRadios.js index af84efa..53c5947 100644 --- a/src/client/funcs/saveRadios.js +++ b/src/client/funcs/saveRadios.js @@ -4,9 +4,10 @@ module.exports = function saveRadios(client) { while (!radio.done) { let currentRadio = client.radio.get(radio.value); - currentRadio.guild = client.datastore.getEntry(radio.value).guild; if (currentRadio) { + currentRadio.guild = client.datastore.getEntry(radio.value).guild; + client.funcs.statisticsUpdate(client, currentRadio.guild, currentRadio); client.funcs.saveState(client, currentRadio.guild, currentRadio); currentRadio.connection?.destroy(); From 7040300b3ead082b8219154f03f6ab438e3d6559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Tue, 14 Sep 2021 18:02:11 +0300 Subject: [PATCH 056/105] Update Streamer class --- src/client/classes/Streamer.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/client/classes/Streamer.js b/src/client/classes/Streamer.js index a841ad7..bccc7f4 100644 --- a/src/client/classes/Streamer.js +++ b/src/client/classes/Streamer.js @@ -56,12 +56,10 @@ module.exports = class { }) .on("finish", () => { this.logger('Streamer', station.name + " / " + "Finished"); - this.map.delete(station.name); this.play(station); }) .on("error", error => { this.logger('Streamer', station.name + " / " + "Error"); - this.map.delete(station.name); this.play(station); }); return audioPlayer; From 9d9c8a6a07984fc6fe33cdb2006232f5ec6a675a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Wed, 15 Sep 2021 17:25:55 +0300 Subject: [PATCH 057/105] Update Streamer class --- src/client/classes/Streamer.js | 45 ++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/src/client/classes/Streamer.js b/src/client/classes/Streamer.js index bccc7f4..d701f3c 100644 --- a/src/client/classes/Streamer.js +++ b/src/client/classes/Streamer.js @@ -1,6 +1,8 @@ const { createAudioPlayer, - createAudioResource + createAudioResource, + AudioPlayerStatus, + NoSubscriberBehavior } = require("@discordjs/voice"); module.exports = class { @@ -43,7 +45,12 @@ module.exports = class { play(station) { let audioPlayer = this.map.get(station.name); if(!audioPlayer) { - audioPlayer = createAudioPlayer(); + audioPlayer = createAudioPlayer({ + behaviors: { + noSubscriber: NoSubscriberBehavior.Play, + maxMissedFrames: Math.round(5000 / 20), + }, + }); this.map.set(station.name, audioPlayer); } const url = station.stream[station.stream.default]; @@ -62,6 +69,40 @@ module.exports = class { this.logger('Streamer', station.name + " / " + "Error"); this.play(station); }); + + + + audioPlayer + .on('playing', () => { + this.logger('Streamer', station.name + " / " + "Playing"); + }) + .on('idle', () => { + this.logger('Streamer', station.name + " / " + "Idle"); + this.play(station); + }) + .on('paused', () => { + this.logger('Streamer', station.name + " / " + "Paused"); + this.play(station); + }) + .on('buffering', () => { + this.logger('Streamer', station.name + " / " + "Buffering"); + }) + .on('autopaused', () => { + this.logger('Streamer', station.name + " / " + "AutoPaused"); + this.play(station); + }) + .on('stateChange', (oldState, newState) => { + if (oldState.status === AudioPlayerStatus.Idle && newState.status === AudioPlayerStatus.Playing) { + this.logger('Streamer', station.name + " / " + "Playing"); + } else if (newState.status === AudioPlayerStatus.Idle) { + this.logger('Streamer', station.name + " / " + "Idle"); + this.play(station); + } + }) + .on('error', (error) => { + this.logger('Streamer', station.name + " / " + "Error" + "\n" + error); + this.play(station); + }); return audioPlayer; } From 4854e622b37b675d6a4403237137fb8974c5fe2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Wed, 15 Sep 2021 17:26:04 +0300 Subject: [PATCH 058/105] Update maintenance command --- src/client/commands/maintenance.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/client/commands/maintenance.js b/src/client/commands/maintenance.js index d161b61..9530568 100644 --- a/src/client/commands/maintenance.js +++ b/src/client/commands/maintenance.js @@ -7,9 +7,6 @@ module.exports = { name: 'maintenance', description: 'Bot Maintenance', category: 'info', - options: [ - { type: "NUMBER", name: "action", description: "Select action", required: false} - ], async execute(interaction, client) { let message = {}; From 48445afdd58f067bfd0cf858e3febaa84c1610fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 01:11:31 +0300 Subject: [PATCH 059/105] Update Streamer event --- src/client/classes/Streamer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/classes/Streamer.js b/src/client/classes/Streamer.js index d701f3c..0707824 100644 --- a/src/client/classes/Streamer.js +++ b/src/client/classes/Streamer.js @@ -99,7 +99,7 @@ module.exports = class { this.play(station); } }) - .on('error', (error) => { + .on('error', error => { this.logger('Streamer', station.name + " / " + "Error" + "\n" + error); this.play(station); }); From bfb27e735914b659b76bfde94208d02f0fa36e0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 01:13:17 +0300 Subject: [PATCH 060/105] Update play command --- src/client/commands/play.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/client/commands/play.js b/src/client/commands/play.js index 52a5a41..ee002a9 100644 --- a/src/client/commands/play.js +++ b/src/client/commands/play.js @@ -15,11 +15,10 @@ module.exports = { let message = {}; if(client.config.maintenanceMode){ - interaction.reply({ + return interaction.reply({ content: client.messageEmojis["error"] + client.messages.maintenance, ephemeral: true }); - return false; } if(!client.stations) { From d64b0ac0cbcebf1f7417af1054e979faa972b482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 01:21:33 +0300 Subject: [PATCH 061/105] Change default streamerMode to manual --- src/client/classes/Streamer.js | 5 ++++- src/config.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/client/classes/Streamer.js b/src/client/classes/Streamer.js index 0707824..46578bb 100644 --- a/src/client/classes/Streamer.js +++ b/src/client/classes/Streamer.js @@ -19,8 +19,11 @@ module.exports = class { case "manual": this.mode = "manual"; break; - default: + case "auto": this.mode = "auto"; + break; + default: + this.mode = "manual"; } if(this.mode == "auto"){ diff --git a/src/config.js b/src/config.js index 0b1eca1..349a47b 100644 --- a/src/config.js +++ b/src/config.js @@ -23,5 +23,5 @@ module.exports = { version: process.env.RADIOX_VERSION || process.env.npm_package_version, debug: process.env.DEBUG_MODE || false, maintenanceMode: false, - streamerMode: process.env.STREAMER_MODE || "auto" + streamerMode: process.env.STREAMER_MODE || "manual" } From 126d5e9ba2c9fea25cb46096fb74f310833c03c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 02:07:05 +0300 Subject: [PATCH 062/105] Update play command --- src/client/commands/play.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/client/commands/play.js b/src/client/commands/play.js index ee002a9..d8795dc 100644 --- a/src/client/commands/play.js +++ b/src/client/commands/play.js @@ -124,9 +124,8 @@ module.exports = { construct.connection = connection; let date = new Date(); construct.startTime = date.getTime(); - client.funcs.play(client, interaction, interaction.guild, station); - client.datastore.checkEntry(interaction.guild.id); + client.funcs.play(client, interaction, interaction.guild, station); } catch (error) { console.log(error); client.radio.delete(interaction.guild.id); From 00f6ee71e01bbbd89e5489a77df11f41f79a9e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 02:17:14 +0300 Subject: [PATCH 063/105] Update interactionCreate event --- src/client/events/interactionCreate.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/events/interactionCreate.js b/src/client/events/interactionCreate.js index 4b37466..c546259 100644 --- a/src/client/events/interactionCreate.js +++ b/src/client/events/interactionCreate.js @@ -6,7 +6,7 @@ module.exports = { if (!permissions.has('VIEW_CHANNEL')) return; if (!permissions.has('EMBED_LINKS')) return interaction.reply({ - content: client.messages.noPermsEmbed, + content: client.messageEmojis["error"] + client.messages.noPermsEmbed, ephemeral: true }); @@ -19,7 +19,7 @@ module.exports = { command.execute(interaction, client); } catch (error) { interaction.reply({ - content: client.messages.runningCommandFailed, + content: client.messageEmojis["error"] + client.messages.runningCommandFailed, ephemeral: true }); console.error(error); @@ -33,7 +33,7 @@ module.exports = { command.execute(interaction, client, command); } catch (error) { interaction.reply({ - content: client.messages.runningCommandFailed, + content: client.messageEmojis["error"] + client.messages.runningCommandFailed, ephemeral: true }); console.error(error); From 09ae458ff1c412f2eef19082c982230d40c158c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 02:26:11 +0300 Subject: [PATCH 064/105] Update play function --- src/client/funcs/play.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/client/funcs/play.js b/src/client/funcs/play.js index 2d4048e..5d2cf19 100644 --- a/src/client/funcs/play.js +++ b/src/client/funcs/play.js @@ -1,7 +1,4 @@ import Discord from "discord.js"; -const { - createAudioResource -} = require("@discordjs/voice"); module.exports = async function play(client, interaction, guild, station) { let message = {}; From a4d984f19c065812d66c619c944d0226f1939edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 02:27:33 +0300 Subject: [PATCH 065/105] Update Datastore class --- src/client/classes/Datastore.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/client/classes/Datastore.js b/src/client/classes/Datastore.js index b18c225..dfcd07d 100644 --- a/src/client/classes/Datastore.js +++ b/src/client/classes/Datastore.js @@ -28,6 +28,8 @@ module.exports = class { } calculateGlobal(client){ + if(!client.stations) return; + let guilds = this.map.keys(); let stations = client.stations; var statistics = {}; From 460a5415e50792b0f58d52843fac9247764d40bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 02:36:06 +0300 Subject: [PATCH 066/105] Update Dependencies --- package-lock.json | 62 +++++++++++++++++++++++------------------------ package.json | 2 +- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/package-lock.json b/package-lock.json index c983b8c..a65c950 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,7 +36,7 @@ "typescript": "^4.4.2" }, "engines": { - "node": ">=16.9.0", + "node": ">=16.9.1", "npm": ">=7.0.0" } }, @@ -447,9 +447,9 @@ } }, "node_modules/@sindresorhus/is": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.1.0.tgz", - "integrity": "sha512-Cgva8HxclecUCmAImsWsbZGUh6p5DSzQ8l2Uzxuj9ANiD7LVhLM1UJ2hX/R2Y+ILpvqgW9QjmTCaBkXtj8+UOg==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.2.0.tgz", + "integrity": "sha512-VkE3KLBmJwcCaVARtQpfuKcKv8gcBmUubrfHGF84dXuuW6jgsRYxPtzcIhPyK9WAPpRt2/xY6zkD9MnRaJzSyw==", "engines": { "node": ">=10" }, @@ -795,9 +795,9 @@ } }, "node_modules/ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true, "engines": { "node": ">=8" @@ -2564,9 +2564,9 @@ "dev": true }, "node_modules/minipass": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.3.tgz", - "integrity": "sha512-Mgd2GdMVzY+x3IJ+oHnVM+KG3lA5c8tnabyJKmHSaG2kAGpudxuOf8ToDkhumF7UzME7DecbQE9uOZhNm7PuJg==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.5.tgz", + "integrity": "sha512-+8NzxD82XQoNKNrl1d/FSi+X8wAEWR+sbYAfIvub4Nz0d22plFG72CEVVaufV8PNf4qSslFTD8VMOxNVhHCjTw==", "dependencies": { "yallist": "^4.0.0" }, @@ -3281,9 +3281,9 @@ } }, "node_modules/signal-exit": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", - "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==" + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.4.tgz", + "integrity": "sha512-rqYhcAnZ6d/vTPGghdrw7iumdcbXpsk1b8IG/rz+VWV51DM0p7XCtMoJ3qhPLIbp3tvyt3pKRbaaEMZYpHto8Q==" }, "node_modules/slash": { "version": "3.0.0", @@ -3449,9 +3449,9 @@ } }, "node_modules/table/node_modules/ajv": { - "version": "8.6.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.6.2.tgz", - "integrity": "sha512-9807RlWAgT564wT+DjeyU5OFMPjmzxVobvDFmNAhY+5zD6A2ly3jDp6sgnfyDtlIQ+7H97oc/DGCzzfu9rjw9w==", + "version": "8.6.3", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.6.3.tgz", + "integrity": "sha512-SMJOdDP6LqTkD0Uq8qLi+gMwSt0imXLSV080qFVwJCpH9U6Mb+SUGHAXM0KNbcBPguytWyvFxcHgMLe2D2XSpw==", "dev": true, "dependencies": { "fast-deep-equal": "^3.1.1", @@ -4325,9 +4325,9 @@ "integrity": "sha512-gPSOQKmEWeuif2ftmW7gyToCnOoqpDqTSNrxX7HsoMwGNLtrT9p5DHcQolkBg5CEK3ooDFy5DNEFKUshQU7vyQ==" }, "@sindresorhus/is": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.1.0.tgz", - "integrity": "sha512-Cgva8HxclecUCmAImsWsbZGUh6p5DSzQ8l2Uzxuj9ANiD7LVhLM1UJ2hX/R2Y+ILpvqgW9QjmTCaBkXtj8+UOg==" + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.2.0.tgz", + "integrity": "sha512-VkE3KLBmJwcCaVARtQpfuKcKv8gcBmUubrfHGF84dXuuW6jgsRYxPtzcIhPyK9WAPpRt2/xY6zkD9MnRaJzSyw==" }, "@szmarczak/http-timer": { "version": "1.1.2", @@ -4559,9 +4559,9 @@ "dev": true }, "ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true }, "ansi-styles": { @@ -5908,9 +5908,9 @@ "dev": true }, "minipass": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.3.tgz", - "integrity": "sha512-Mgd2GdMVzY+x3IJ+oHnVM+KG3lA5c8tnabyJKmHSaG2kAGpudxuOf8ToDkhumF7UzME7DecbQE9uOZhNm7PuJg==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.5.tgz", + "integrity": "sha512-+8NzxD82XQoNKNrl1d/FSi+X8wAEWR+sbYAfIvub4Nz0d22plFG72CEVVaufV8PNf4qSslFTD8VMOxNVhHCjTw==", "requires": { "yallist": "^4.0.0" } @@ -6406,9 +6406,9 @@ "dev": true }, "signal-exit": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", - "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==" + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.4.tgz", + "integrity": "sha512-rqYhcAnZ6d/vTPGghdrw7iumdcbXpsk1b8IG/rz+VWV51DM0p7XCtMoJ3qhPLIbp3tvyt3pKRbaaEMZYpHto8Q==" }, "slash": { "version": "3.0.0", @@ -6536,9 +6536,9 @@ }, "dependencies": { "ajv": { - "version": "8.6.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.6.2.tgz", - "integrity": "sha512-9807RlWAgT564wT+DjeyU5OFMPjmzxVobvDFmNAhY+5zD6A2ly3jDp6sgnfyDtlIQ+7H97oc/DGCzzfu9rjw9w==", + "version": "8.6.3", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.6.3.tgz", + "integrity": "sha512-SMJOdDP6LqTkD0Uq8qLi+gMwSt0imXLSV080qFVwJCpH9U6Mb+SUGHAXM0KNbcBPguytWyvFxcHgMLe2D2XSpw==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", diff --git a/package.json b/package.json index 8571515..90253ed 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "typescript": "^4.4.2" }, "engines": { - "node": ">=16.9.0", + "node": ">=16.9.1", "npm": ">=7.0.0" } } From 341bddd4cd70386a07a91e4ff8203ca11da3c9e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 02:51:07 +0300 Subject: [PATCH 067/105] Update .env_example --- .env_example | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.env_example b/.env_example index 8ff64e7..51fcae4 100644 --- a/.env_example +++ b/.env_example @@ -1,2 +1,5 @@ DISCORD_TOKEN= RADIOX_STATIONSLISTURL=https://gitea.cwinfo.org/cwchristerw/radio/raw/branch/master/playlist.json +DEV_MODE=false +DEBUG_MODE=false +STREAMER_MODE=manual From c829f70418b2175aa0f218c22f71e80c37fe8a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 02:52:24 +0300 Subject: [PATCH 068/105] Add devMode to config --- src/config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/config.js b/src/config.js index 349a47b..e15f034 100644 --- a/src/config.js +++ b/src/config.js @@ -20,8 +20,9 @@ module.exports = { hostedBy: "[Warén Group](https://waren.io)", //Settings - version: process.env.RADIOX_VERSION || process.env.npm_package_version, + version: process.env.DEV_MODE ? process.env.npm_package_version + "-dev" : process.env.npm_package_version, debug: process.env.DEBUG_MODE || false, + devMode: process.env.DEV_MODE || false, maintenanceMode: false, streamerMode: process.env.STREAMER_MODE || "manual" } From ebf1d0759ef359311fa772647296a2fdb50915c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 02:52:40 +0300 Subject: [PATCH 069/105] Update commands.js --- src/client/commands.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/client/commands.js b/src/client/commands.js index 9641933..36e691e 100644 --- a/src/client/commands.js +++ b/src/client/commands.js @@ -1,7 +1,6 @@ const { SlashCommandBuilder } = require('@discordjs/builders'); const { REST } = require('@discordjs/rest'); const { Routes } = require('discord-api-types/v9'); -const { token, version } = require('../config.js'); const fs = require('fs'); const path = require ('path'); @@ -28,13 +27,13 @@ module.exports = { commands.push(command.data); } - const rest = new REST({ version: '9' }).setToken(token); + const rest = new REST({ version: '9' }).setToken(client.config.token); (async () => { try { client.funcs.logger('Slash Commands', 'Started refreshing application (/) commands.'); - if(version.includes("-dev")){ + if(client.config.devMode){ await rest.put( Routes.applicationCommands(client.user.id), { body: [] }, From 8d5291cbb0793fb2690df4d9aadab4db886d6fe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 03:17:50 +0300 Subject: [PATCH 070/105] Moved commands map to commands.js --- src/Client.ts | 6 ------ src/client/commands.js | 3 +++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Client.ts b/src/Client.ts index aba71a5..d75f336 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -59,12 +59,6 @@ class RadioClient extends Client { this.funcs.logger("Maintenance Mode", "Enabled"); this.config.maintenanceMode = true; - const commandFiles = fs.readdirSync(path.join("./src/client/commands")).filter(f => f.endsWith(".js")); - for (const file of commandFiles) { - const command = require(`./client/commands/${file}`); - this.commands.set(command.name, command); - } - this.on("ready", () => { require(`${events}ready`).execute(this); }); diff --git a/src/client/commands.js b/src/client/commands.js index 36e691e..9d4325b 100644 --- a/src/client/commands.js +++ b/src/client/commands.js @@ -6,11 +6,14 @@ const path = require ('path'); module.exports = { async execute(client) { + const commands = []; const commandFiles = fs.readdirSync(path.join("./src/client/commands")).filter(f => f.endsWith(".js")); for (const file of commandFiles) { const command = require(`./commands/${file}`); + client.commands.set(command.name, command); + command.data = new SlashCommandBuilder() .setName(command.name) .setDescription(command.description); From 72c160950377a3452534c09afc06486d2a7b10e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 03:19:25 +0300 Subject: [PATCH 071/105] Update statusField order in status.js --- src/client/commands/status.js | 10 +++++----- src/client/messages.js | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/client/commands/status.js b/src/client/commands/status.js index 66eb727..3f9ae9d 100644 --- a/src/client/commands/status.js +++ b/src/client/commands/status.js @@ -14,11 +14,11 @@ module.exports = { .setTitle(message.statusTitle) .setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["logo"].replace(/[^0-9]+/g, '')) .setColor(client.config.embedColor) - .addField(client.messages.statusField1, Date.now() - interaction.createdTimestamp + "ms", true) - .addField(client.messages.statusField2, client.ws.ping + "ms", true) - .addField(client.messages.statusField3, uptime, true) - .addField(client.messages.statusField4, client.config.version, true) - .addField(client.messages.statusField5, client.config.hostedBy, true) + .addField(client.messages.statusField1, uptime, false) + .addField(client.messages.statusField2, client.config.version, false) + .addField(client.messages.statusField3, Date.now() - interaction.createdTimestamp + "ms", false) + .addField(client.messages.statusField4, client.ws.ping + "ms", false) + .addField(client.messages.statusField5, client.config.hostedBy, false) .setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png') .setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')); diff --git a/src/client/messages.js b/src/client/messages.js index f893ff8..eb26915 100644 --- a/src/client/messages.js +++ b/src/client/messages.js @@ -29,11 +29,11 @@ module.exports = { sendedMaintenanceMessage: "This bot is going to be under maintenance!", footerText: "EximiaBots by Warén Group", statusTitle: "%client.user.username% Status", - statusField1: "Bot Latency", - statusField2: "API Latency", - statusField3: "Uptime", - statusField4: "Version", - statusField5: "Hosted by", + statusField1: ":clock1: Bot Uptime", + statusField2: ":floppy_disk: Bot Version", + statusField3: ":heartbeat: WebSocket Ping", + statusField4: ":hourglass: Latency", + statusField5: ":globe_with_meridians: Hosted by", errorStationURL: "Station can't be URL", messageCommandsDeprecatedTitle: "%client.user.username%", messageCommandsDeprecatedDescription: "We recommend you to reauthorize our bot by clicking the invite link down below, because Discord is planning to remove message content from verified bots [Read More](https://support-dev.discord.com/hc/en-us/articles/4404772028055)" + "\n\n" + "**Invite Bot**" + "\n" + "https://wgi.fi/radiox_invite" + "\n\n" + "This bot now supports slash commands, you should start using them instead. Type / into the message box and select the bot you wish to use. Remember to be careful as there are a few bugs here and there on Discord." + "\n\n" + "We will remove this deprecation message in March of 2022 when RadioX 1.0.0 is released.", From 469374f25e78709ce945963de9f988d46f3145cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 03:34:31 +0300 Subject: [PATCH 072/105] Update Streamer class --- src/client/classes/Streamer.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/client/classes/Streamer.js b/src/client/classes/Streamer.js index 46578bb..5aacf9a 100644 --- a/src/client/classes/Streamer.js +++ b/src/client/classes/Streamer.js @@ -94,14 +94,6 @@ module.exports = class { this.logger('Streamer', station.name + " / " + "AutoPaused"); this.play(station); }) - .on('stateChange', (oldState, newState) => { - if (oldState.status === AudioPlayerStatus.Idle && newState.status === AudioPlayerStatus.Playing) { - this.logger('Streamer', station.name + " / " + "Playing"); - } else if (newState.status === AudioPlayerStatus.Idle) { - this.logger('Streamer', station.name + " / " + "Idle"); - this.play(station); - } - }) .on('error', error => { this.logger('Streamer', station.name + " / " + "Error" + "\n" + error); this.play(station); From b351bbebed30c6fbac3039afc17525056d42a53b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 04:46:30 +0300 Subject: [PATCH 073/105] Add Radio class --- src/client/classes/Radio.js | 84 +++++++++++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 4 deletions(-) diff --git a/src/client/classes/Radio.js b/src/client/classes/Radio.js index e371498..00d6bfc 100644 --- a/src/client/classes/Radio.js +++ b/src/client/classes/Radio.js @@ -1,10 +1,86 @@ -module.exports = class { +const { + getVoiceConnection, + joinVoiceChannel +} = require("@discordjs/voice"); + +module.exports = class Radio extends Map { constructor() { - this.map = new Map(); - this.example(); + super(); } - example() { + save(client) { + let currentRadios = this.keys(); + let radio = currentRadios.next(); + while (!radio.done) { + let currentRadio = this.get(radio.value); + + if (currentRadio) { + currentRadio.guild = client.datastore.getEntry(radio.value).guild; + + client.statistics.update(client, currentRadio.guild, currentRadio); + client.funcs.saveState(client, currentRadio.guild, currentRadio); + currentRadio.connection?.destroy(); + currentRadio.message?.delete(); + this.delete(radio.value); + } + + radio = currentRadios.next(); + } } + + restore(client, guilds) { + if(!client.stations.list) return; + + guilds.forEach(async guild => { + let state = client.funcs.loadState(client, guild); + if(!state) return; + if(!state.station || !state.channels.voice || !state.channels.text) return; + let voiceChannel = client.channels.cache.get(state.channels.voice); + if(!voiceChannel) return; + if(voiceChannel.members.size === 0) return; + + + const sstation = await client.stations.search(state.station.name); + let station = sstation; + + const construct = { + textChannel: client.channels.cache.get(state.channels.text), + voiceChannel: client.channels.cache.get(state.channels.voice), + connection: null, + message: null, + station: station + }; + this.list.set(guild.id, construct); + + try { + const connection = + getVoiceConnection(guild.id) ?? + joinVoiceChannel({ + channelId: voiceChannel.id, + guildId: voiceChannel.guild.id, + adapterCreator: voiceChannel.guild.voiceAdapterCreator + }); + + 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); + } + } catch (error) { + console.log(error); + } + }); + } + }; From dfa9548b5997d311aa597615c02628b7433a785b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 04:46:42 +0300 Subject: [PATCH 074/105] Add Stations class --- src/client/classes/Stations.js | 105 +++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 src/client/classes/Stations.js diff --git a/src/client/classes/Stations.js b/src/client/classes/Stations.js new file mode 100644 index 0000000..4f9a631 --- /dev/null +++ b/src/client/classes/Stations.js @@ -0,0 +1,105 @@ +const _importDynamic = new Function('modulePath', 'return import(modulePath)'); +const fetch = (...args) => _importDynamic('node-fetch').then(({default: fetch}) => fetch(...args)); + +module.exports = class { + constructor() { + this.list = new Array(); + this.logger = require("../funcs/logger.js"); + } + + async fetch(options){ + try { + this.logger('Stations', 'Started fetching list – ' + options.url); + let list = await fetch(options.url) + .then(this.checkFetchStatus) + .then(response => response.json()); + + if(!this.list){ + this.logger('Stations'); + this.list.forEach(station => { + console.log("- " + station.name); + }); + console.log("\n"); + } + + this.list = list; + this.logger('Stations', 'Successfully fetched list'); + } catch (error) { + this.logger('Stations', 'Fetching list failed'); + console.error(error + "\n"); + + this.fetch(options); + } + } + + checkFetchStatus(response) { + if (response.ok) { // res.status >= 200 && res.status < 300 + return response; + } else { + throw new Error(response.status + " " + response.statusText); + } + } + + search(key) { + if (this.list === null) return false; + let foundStations = []; + if (!key) return false; + if (key == "radio") return false; + + this.list + .filter( + x => x.name.toUpperCase().includes(key.toUpperCase()) || x === key + ) + .forEach(x => + foundStations.push({ station: x, name: x.name, probability: 100 }) + ); + + if (key.startsWith("radio ")) key = key.slice(6); + const probabilityIncrement = 100 / key.split(" ").length / 2; + for (let i = 0; i < key.split(" ").length; i++) { + this.list + .filter( + x => x.name.toUpperCase().includes(key.split(" ")[i].toUpperCase()) || x === key + ) + .forEach(x => + foundStations.push({ station: x, name: x.name, probability: probabilityIncrement }) + ); + } + if (foundStations.length === 0) return false; + for (let i = 0; i < foundStations.length; i++) { + for (let j = 0; j < foundStations.length; j++) { + if (foundStations[i] === foundStations[j] && i !== j) foundStations.splice(i, 1); + } + } + for (let i = 0; i < foundStations.length; i++) { + if (foundStations[i].name.length > key.length) { + foundStations[i].probability -= + (foundStations[i].name.split(" ").length - key.split(" ").length) * + (probabilityIncrement * 0.5); + } else if (foundStations[i].name.length === key.length) { + foundStations[i].probability += probabilityIncrement * 0.9; + } + + for (let j = 0; j < key.split(" ").length; j++) { + if (!foundStations[i].name.toUpperCase().includes(key.toUpperCase().split(" ")[j])) { + foundStations[i].probability -= probabilityIncrement * 0.5; + } + } + } + let highestProbabilityStation; + for (let i = 0; i < foundStations.length; i++) { + if ( + !highestProbabilityStation || + highestProbabilityStation.probability < foundStations[i].probability + ) + highestProbabilityStation = foundStations[i]; + if ( + highestProbabilityStation && + highestProbabilityStation.probability === foundStations[i].probability + ) { + highestProbabilityStation = foundStations[i].station; + } + } + return highestProbabilityStation; + } +}; From 330c33b3d7a492ea17839edc73d28975d135316d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 04:46:54 +0300 Subject: [PATCH 075/105] Add Statistics class --- src/client/classes/Statistics.js | 70 ++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/client/classes/Statistics.js diff --git a/src/client/classes/Statistics.js b/src/client/classes/Statistics.js new file mode 100644 index 0000000..0387177 --- /dev/null +++ b/src/client/classes/Statistics.js @@ -0,0 +1,70 @@ +module.exports = class { + constructor() { + this.map = new Map(); + } + + update(client, guild, radio) { + + client.datastore.checkEntry(guild.id); + + radio.datastore = client.datastore.getEntry(guild.id); + + if(!radio.datastore.statistics[radio.station.name]){ + radio.datastore.statistics[radio.station.name] = {}; + radio.datastore.statistics[radio.station.name].time = 0; + radio.datastore.statistics[radio.station.name].used = 0; + client.datastore.updateEntry(guild, radio.datastore); + } + + let date = new Date(); + radio.currentTime = date.getTime(); + radio.playTime = parseInt(radio.currentTime)-parseInt(radio.startTime); + radio.datastore.statistics[radio.station.name].time = parseInt(radio.datastore.statistics[radio.station.name].time)+parseInt(radio.playTime); + + radio.datastore.statistics[radio.station.name].used = parseInt(radio.datastore.statistics[radio.station.name].used)+1; + client.datastore.updateEntry(guild, radio.datastore); + this.calculateGlobal(client); + } + + calculateGlobal(client){ + if(!client.stations.list) return; + if(!client.datastore.map) return; + + let guilds = client.datastore.map.keys(); + let stations = client.stations.list; + let statistics = {}; + + if(!client.stations.list) return; + + let calculation = guilds.next(); + + while (!calculation.done) { + let currentGuild = client.datastore.getEntry(calculation.value); + if(calculation.value != 'global'){ + if(stations){ + Object.keys(stations).forEach(function(station) { + if(currentGuild.statistics[stations[station].name] && currentGuild.statistics[stations[station].name].time && parseInt(currentGuild.statistics[stations[station].name].time) != 0 && currentGuild.statistics[stations[station].name].used && parseInt(currentGuild.statistics[stations[station].name].used) != 0){ + if(!statistics[stations[station].name]){ + statistics[stations[station].name] = {}; + statistics[stations[station].name].time = 0; + statistics[stations[station].name].used = 0; + } + + statistics[stations[station].name].time = parseInt(statistics[stations[station].name].time)+parseInt(currentGuild.statistics[stations[station].name].time); + statistics[stations[station].name].used = parseInt(statistics[stations[station].name].used)+parseInt(currentGuild.statistics[stations[station].name].used); + } + }); + } + } + calculation = guilds.next(); + } + + let newData = {}; + newData.guild = {}; + newData.guild.id = "global"; + newData.guild.name = "global"; + newData.statistics = statistics; + client.datastore.updateEntry(newData.guild, newData); + } + +}; From 348b540c063f345a9d29e69edb6ca987a3252ec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 04:48:58 +0300 Subject: [PATCH 076/105] Remove few functions --- src/client/funcs/checkFetchStatus.js | 7 ---- src/client/funcs/restoreRadios.js | 59 -------------------------- src/client/funcs/saveRadios.js | 20 --------- src/client/funcs/searchStation.js | 62 ---------------------------- src/client/funcs/statisticsUpdate.js | 22 ---------- 5 files changed, 170 deletions(-) delete mode 100644 src/client/funcs/checkFetchStatus.js delete mode 100644 src/client/funcs/restoreRadios.js delete mode 100644 src/client/funcs/saveRadios.js delete mode 100644 src/client/funcs/searchStation.js delete mode 100644 src/client/funcs/statisticsUpdate.js diff --git a/src/client/funcs/checkFetchStatus.js b/src/client/funcs/checkFetchStatus.js deleted file mode 100644 index cd45e30..0000000 --- a/src/client/funcs/checkFetchStatus.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = function checkFetchStatus(response) { - if (response.ok) { // res.status >= 200 && res.status < 300 - return response; - } else { - throw new Error(response.status + " " + response.statusText); - } -} diff --git a/src/client/funcs/restoreRadios.js b/src/client/funcs/restoreRadios.js deleted file mode 100644 index b83243f..0000000 --- a/src/client/funcs/restoreRadios.js +++ /dev/null @@ -1,59 +0,0 @@ -import Discord from "discord.js"; -const { - getVoiceConnection, - joinVoiceChannel -} = require("@discordjs/voice"); - -module.exports = async function restoreRadios(client, guilds) { - if(!client.stations) return; - - guilds.forEach(async guild => { - let state = client.funcs.loadState(client, guild); - if(!state) return; - if(!state.station || !state.channels.voice || !state.channels.text) return; - let voiceChannel = client.channels.cache.get(state.channels.voice); - if(!voiceChannel) return; - if(voiceChannel.members.size === 0) return; - - - const sstation = await client.funcs.searchStation(state.station.name, client); - let station = sstation; - - const construct = { - textChannel: client.channels.cache.get(state.channels.text), - voiceChannel: client.channels.cache.get(state.channels.voice), - connection: null, - message: null, - station: station - }; - client.radio.set(guild.id, construct); - - try { - const connection = - getVoiceConnection(guild.id) ?? - joinVoiceChannel({ - channelId: voiceChannel.id, - guildId: voiceChannel.guild.id, - adapterCreator: voiceChannel.guild.voiceAdapterCreator - }); - - 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); - } - } catch (error) { - console.log(error); - } - }); -} diff --git a/src/client/funcs/saveRadios.js b/src/client/funcs/saveRadios.js deleted file mode 100644 index 53c5947..0000000 --- a/src/client/funcs/saveRadios.js +++ /dev/null @@ -1,20 +0,0 @@ -module.exports = function saveRadios(client) { - let currentRadios = client.radio.keys(); - let radio = currentRadios.next(); - - while (!radio.done) { - let currentRadio = client.radio.get(radio.value); - - if (currentRadio) { - currentRadio.guild = client.datastore.getEntry(radio.value).guild; - - client.funcs.statisticsUpdate(client, currentRadio.guild, currentRadio); - client.funcs.saveState(client, currentRadio.guild, currentRadio); - currentRadio.connection?.destroy(); - currentRadio.message?.delete(); - client.radio.delete(radio.value); - } - - radio = currentRadios.next(); - } -} diff --git a/src/client/funcs/searchStation.js b/src/client/funcs/searchStation.js deleted file mode 100644 index 9206722..0000000 --- a/src/client/funcs/searchStation.js +++ /dev/null @@ -1,62 +0,0 @@ -module.exports = function searchStation(key, client) { - if (client.stations === null) return false; - let foundStations = []; - if (!key) return false; - if (key == "radio") return false; - - client.stations - .filter( - x => x.name.toUpperCase().includes(key.toUpperCase()) || x === key - ) - .forEach(x => - foundStations.push({ station: x, name: x.name, probability: 100 }) - ); - - if (key.startsWith("radio ")) key = key.slice(6); - const probabilityIncrement = 100 / key.split(" ").length / 2; - for (let i = 0; i < key.split(" ").length; i++) { - client.stations - .filter( - x => x.name.toUpperCase().includes(key.split(" ")[i].toUpperCase()) || x === key - ) - .forEach(x => - foundStations.push({ station: x, name: x.name, probability: probabilityIncrement }) - ); - } - if (foundStations.length === 0) return false; - for (let i = 0; i < foundStations.length; i++) { - for (let j = 0; j < foundStations.length; j++) { - if (foundStations[i] === foundStations[j] && i !== j) foundStations.splice(i, 1); - } - } - for (let i = 0; i < foundStations.length; i++) { - if (foundStations[i].name.length > key.length) { - foundStations[i].probability -= - (foundStations[i].name.split(" ").length - key.split(" ").length) * - (probabilityIncrement * 0.5); - } else if (foundStations[i].name.length === key.length) { - foundStations[i].probability += probabilityIncrement * 0.9; - } - - for (let j = 0; j < key.split(" ").length; j++) { - if (!foundStations[i].name.toUpperCase().includes(key.toUpperCase().split(" ")[j])) { - foundStations[i].probability -= probabilityIncrement * 0.5; - } - } - } - let highestProbabilityStation; - for (let i = 0; i < foundStations.length; i++) { - if ( - !highestProbabilityStation || - highestProbabilityStation.probability < foundStations[i].probability - ) - highestProbabilityStation = foundStations[i]; - if ( - highestProbabilityStation && - highestProbabilityStation.probability === foundStations[i].probability - ) { - highestProbabilityStation = foundStations[i].station; - } - } - return highestProbabilityStation; -} diff --git a/src/client/funcs/statisticsUpdate.js b/src/client/funcs/statisticsUpdate.js deleted file mode 100644 index fcd3ad1..0000000 --- a/src/client/funcs/statisticsUpdate.js +++ /dev/null @@ -1,22 +0,0 @@ -module.exports = function statisticsUpdate(client, guild, radio) { - - client.datastore.checkEntry(guild.id); - - radio.datastore = client.datastore.getEntry(guild.id); - - if(!radio.datastore.statistics[radio.station.name]){ - radio.datastore.statistics[radio.station.name] = {}; - radio.datastore.statistics[radio.station.name].time = 0; - radio.datastore.statistics[radio.station.name].used = 0; - client.datastore.updateEntry(guild, radio.datastore); - } - - let date = new Date(); - radio.currentTime = date.getTime(); - radio.playTime = parseInt(radio.currentTime)-parseInt(radio.startTime); - radio.datastore.statistics[radio.station.name].time = parseInt(radio.datastore.statistics[radio.station.name].time)+parseInt(radio.playTime); - - radio.datastore.statistics[radio.station.name].used = parseInt(radio.datastore.statistics[radio.station.name].used)+1; - client.datastore.updateEntry(guild, radio.datastore); - client.datastore.calculateGlobal(client); -} From 7d38170ba6628fd8ce9fe68f525b1172dd23dbed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 04:50:44 +0300 Subject: [PATCH 077/105] Removed calculateGlobal function in Datastore class --- src/client/classes/Datastore.js | 41 --------------------------------- 1 file changed, 41 deletions(-) diff --git a/src/client/classes/Datastore.js b/src/client/classes/Datastore.js index dfcd07d..d219b27 100644 --- a/src/client/classes/Datastore.js +++ b/src/client/classes/Datastore.js @@ -27,47 +27,6 @@ module.exports = class { //console.log(""); } - calculateGlobal(client){ - if(!client.stations) return; - - let guilds = this.map.keys(); - let stations = client.stations; - var statistics = {}; - - if(!client.stations) return; - - let calculation = guilds.next(); - - while (!calculation.done) { - let currentGuild = this.getEntry(calculation.value); - if(calculation.value != 'global'){ - if(stations){ - Object.keys(stations).forEach(function(station) { - if(currentGuild.statistics[stations[station].name] && currentGuild.statistics[stations[station].name].time && parseInt(currentGuild.statistics[stations[station].name].time) != 0 && currentGuild.statistics[stations[station].name].used && parseInt(currentGuild.statistics[stations[station].name].used) != 0){ - if(!statistics[stations[station].name]){ - statistics[stations[station].name] = {}; - statistics[stations[station].name].time = 0; - statistics[stations[station].name].used = 0; - } - - statistics[stations[station].name].time = parseInt(statistics[stations[station].name].time)+parseInt(currentGuild.statistics[stations[station].name].time); - statistics[stations[station].name].used = parseInt(statistics[stations[station].name].used)+parseInt(currentGuild.statistics[stations[station].name].used); - } - }); - } - } - calculation = guilds.next(); - } - - let newData = {}; - newData.guild = {}; - newData.guild.id = "global"; - newData.guild.name = "global"; - newData.statistics = statistics; - this.updateEntry(newData.guild, newData); - } - - checkEntry(id){ this.loadEntry(id); if(!this.map.has(id)){ From bfba8304e42e365b1f479c2cf20c3d01c31701a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 04:51:23 +0300 Subject: [PATCH 078/105] Update Streamer class --- src/client/classes/Streamer.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/client/classes/Streamer.js b/src/client/classes/Streamer.js index 5aacf9a..895c6a3 100644 --- a/src/client/classes/Streamer.js +++ b/src/client/classes/Streamer.js @@ -27,9 +27,9 @@ module.exports = class { } if(this.mode == "auto"){ - if(!client.stations) return; + if(!client.stations.list) return; - client.stations.forEach(station => { + client.stations.list.forEach(station => { this.play(station); }); } @@ -40,7 +40,7 @@ module.exports = class { let streamers = this.map.keys(); streamers.forEach(streamer => { - if(client.stations.findIndex(station => station.name == streamer)) return; + if(client.stations.list.findIndex(station => station.name == streamer)) return; this.stop(streamer); }); } @@ -119,9 +119,9 @@ module.exports = class { } leave(client) { - if(!client.stations) return; + if(!client.stations.list) return; - client.stations.forEach(station => { + client.stations.list.forEach(station => { this.stop(station); }); } From 6d22dda0aed71efad7903c1156e80929cd7ab89d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 04:51:36 +0300 Subject: [PATCH 079/105] Update Client.ts --- src/Client.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Client.ts b/src/Client.ts index d75f336..b15df2e 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -1,7 +1,9 @@ import Discord, { Client, Collection } from "discord.js"; import Datastore from "./client/classes/Datastore.js"; import Radio from "./client/classes/Radio.js"; +import Stations from "./client/classes/Stations.js"; import Streamer from "./client/classes/Streamer.js"; +import Statistics from "./client/classes/Statistics.js"; import fs from "fs"; import { command, radio } from "./client/utils/typings.js"; import config from "./config.js"; @@ -19,35 +21,34 @@ GatewayIntents.add( class RadioClient extends Client { readonly commands: Collection; - readonly radio: Map; public funcs: any; readonly config = config; readonly messages = messages; public datastore: Datastore | null; + public stations: Stations | null; public streamer: Streamer | null; + public statistics: Statistics | null; + public radio: Radio | null; constructor() { super({ intents: GatewayIntents }); this.commands = new Collection(); - this.radio = new Map(); this.datastore = null; + this.stations = null; this.streamer = null; + this.statistics = null; + this.radio = null; this.funcs = {}; this.funcs.check = require("./client/funcs/check.js"); - this.funcs.checkFetchStatus = require("./client/funcs/checkFetchStatus.js"); this.funcs.isDev = require("./client/funcs/isDev.js"); this.funcs.logger = require("./client/funcs/logger.js"); this.funcs.msToTime = require("./client/funcs/msToTime.js"); - this.funcs.statisticsUpdate = require("./client/funcs/statisticsUpdate.js"); this.funcs.saveState = require("./client/funcs/saveState.js"); this.funcs.loadState = require("./client/funcs/loadState.js"); - this.funcs.searchStation = require("./client/funcs/searchStation.js"); this.funcs.play = require("./client/funcs/play.js"); this.funcs.listStations = require("./client/funcs/listStations.js"); - this.funcs.restoreRadios = require("./client/funcs/restoreRadios.js"); - this.funcs.saveRadios = require("./client/funcs/saveRadios.js"); console.log('RadioX ' + this.config.version); console.log('Internet Radio to your Discord guild'); From c7ddc6ec5bdcff0088ec8bcd3a1b643c599ef3e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 04:52:30 +0300 Subject: [PATCH 080/105] Update multiple commands --- src/client/commands/list.js | 4 ++-- src/client/commands/maintenance.js | 22 +++++++++------------- src/client/commands/next.js | 8 ++++---- src/client/commands/play.js | 10 +++++----- src/client/commands/prev.js | 8 ++++---- src/client/commands/statistics.js | 4 ++-- src/client/commands/stop.js | 2 +- 7 files changed, 27 insertions(+), 31 deletions(-) diff --git a/src/client/commands/list.js b/src/client/commands/list.js index 70ba290..00d73b9 100644 --- a/src/client/commands/list.js +++ b/src/client/commands/list.js @@ -7,7 +7,7 @@ module.exports = { execute(interaction, client) { let message = {}; - if(!client.stations) { + if(!client.stations.list) { message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild); return interaction.reply({ content: client.messageEmojis["error"] + message.errorToGetPlaylist, @@ -20,7 +20,7 @@ module.exports = { if(radio && !client.config.maintenanceMode){ client.funcs.listStations(client, interaction); } else { - let stations = `${client.stations.map(s => `**#** ${s.name}`).join('\n')}` + let stations = `${client.stations.list.map(s => `**#** ${s.name}`).join('\n')}` const hashs = stations.split('**#**').length; for (let i = 0; i < hashs; i++) { stations = stations.replace('**#**', `**${i + 1}.**`); diff --git a/src/client/commands/maintenance.js b/src/client/commands/maintenance.js index 9530568..d9d3547 100644 --- a/src/client/commands/maintenance.js +++ b/src/client/commands/maintenance.js @@ -111,14 +111,14 @@ module.exports = { case "4": client.config.maintenanceMode = true; client.user.setStatus('idle'); - client.funcs.saveRadios(client); + client.radio.save(client); client.user.setStatus('online'); client.config.maintenanceMode = false; break; case "5": client.config.maintenanceMode = true; client.user.setStatus('idle'); - client.funcs.restoreRadios(client, guilds); + client.radio.restore(client, guilds); client.user.setStatus('online'); client.config.maintenanceMode = false; break; @@ -131,17 +131,13 @@ module.exports = { break; case "7": try { - client.funcs.logger('Stations', 'Started fetching list – ' + client.config.stationslistUrl); - client.stations = await fetch(client.config.stationslistUrl) - .then(client.funcs.checkFetchStatus) - .then(response => response.json()); - - client.funcs.logger('Stations', 'Successfully fetched list'); - + client.stations.fetch({ + url: client.config.stationslistUrl + }); client.streamer.refresh(client); } catch (error) { - client.funcs.logger('Stations', 'Fetching list failed'); + } break; case "8": @@ -167,7 +163,7 @@ module.exports = { client.streamer = new Streamer(); client.streamer.init(client); - client.funcs.restoreRadios(client, guilds); + client.radio.restore(client, guilds); client.user.setStatus('online'); client.config.maintenanceMode = false; } @@ -183,7 +179,7 @@ module.exports = { client.config.maintenanceMode = true; client.user.setStatus('idle'); - client.funcs.saveRadios(client); + client.funcs.save(client); setInterval(() => { if(client.radio.size == 0 && client.config.streamerMode == "auto" && client.config.maintenanceMode){ @@ -191,7 +187,7 @@ module.exports = { client.streamer = new Streamer(); client.streamer.init(client); - client.funcs.restoreRadios(client, guilds); + client.radio.restore(client, guilds); client.user.setStatus('online'); client.config.maintenanceMode = false; } diff --git a/src/client/commands/next.js b/src/client/commands/next.js index 345faa7..3f0114f 100644 --- a/src/client/commands/next.js +++ b/src/client/commands/next.js @@ -6,17 +6,17 @@ module.exports = { if (client.funcs.check(client, interaction, command)) { const radio = client.radio.get(interaction.guild.id); - let index = client.stations.findIndex(station => station.name == radio.station.name) + 1; - if(index == client.stations.length) index = 0; + let index = client.stations.list.findIndex(station => station.name == radio.station.name) + 1; + if(index == client.stations.list.length) index = 0; - let station = client.stations[index]; + let station = client.stations.list[index]; if(!station) return interaction.reply({ content: client.messageEmojis["error"] + client.messages.noSearchResults, ephemeral: true }); - client.funcs.statisticsUpdate(client, interaction.guild, radio); + client.statistics.update(client, interaction.guild, radio); let date = new Date(); radio.station = station; diff --git a/src/client/commands/play.js b/src/client/commands/play.js index d8795dc..62b65a8 100644 --- a/src/client/commands/play.js +++ b/src/client/commands/play.js @@ -21,7 +21,7 @@ module.exports = { }); } - if(!client.stations) { + if(!client.stations.list) { message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild); return interaction.reply({ content: client.messageEmojis["error"] + message.errorToGetPlaylist, @@ -71,20 +71,20 @@ module.exports = { ephemeral: true }); } else if (!isNaN(number)) { - if (number > client.stations.length - 1) { + if (number > client.stations.list.length - 1) { return interaction.reply({ content: client.messageEmojis["error"] + client.messages.wrongStationNumber, ephemeral: true }); } else { - station = client.stations[number]; + station = client.stations.list[number]; } } else { if (query.length < 3) return interaction.reply({ content: client.messageEmojis["error"] + client.messages.tooShortSearch, ephemeral: true }); - const sstation = await client.funcs.searchStation(query, client); + const sstation = await client.stations.search(query, client); if (!sstation) return interaction.reply({ content: client.messageEmojis["error"] + client.messages.noSearchResults, ephemeral: true @@ -93,7 +93,7 @@ module.exports = { } if (radio) { - client.funcs.statisticsUpdate(client, interaction.guild, radio); + client.statistics.update(client, interaction.guild, radio); let date = new Date(); radio.station = station; diff --git a/src/client/commands/prev.js b/src/client/commands/prev.js index 3db911b..6189919 100644 --- a/src/client/commands/prev.js +++ b/src/client/commands/prev.js @@ -6,17 +6,17 @@ module.exports = { if (client.funcs.check(client, interaction, command)) { const radio = client.radio.get(interaction.guild.id); - let index = client.stations.findIndex(station => station.name == radio.station.name) - 1; - if(index == -1) index = client.stations.length - 1; + let index = client.stations.list.findIndex(station => station.name == radio.station.name) - 1; + if(index == -1) index = client.stations.list.length - 1; - let station = client.stations[index]; + let station = client.stations.list[index]; if(!station) return interaction.reply({ content: client.messageEmojis["error"] + client.messages.noSearchResults, ephemeral: true }); - client.funcs.statisticsUpdate(client, interaction.guild, radio); + client.statistics.update(client, interaction.guild, radio); let date = new Date(); radio.station = station; diff --git a/src/client/commands/statistics.js b/src/client/commands/statistics.js index 56c533c..6c3f42b 100644 --- a/src/client/commands/statistics.js +++ b/src/client/commands/statistics.js @@ -7,12 +7,12 @@ module.exports = { category: 'info', execute(interaction, client) { let message = {}; - let stations = client.stations; + let stations = client.stations.list; let currentGuild = client.datastore.getEntry(interaction.guild.id); let global = client.datastore.getEntry("global"); let statistics = ""; - if(!client.stations) { + if(!client.stations.list) { message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild); return interaction.reply({ content: client.messageEmojis["error"] + message.errorToGetPlaylist, diff --git a/src/client/commands/stop.js b/src/client/commands/stop.js index 84674fc..55d0212 100644 --- a/src/client/commands/stop.js +++ b/src/client/commands/stop.js @@ -7,7 +7,7 @@ module.exports = { async execute(interaction, client, command) { if (client.funcs.check(client, interaction, command)) { const radio = client.radio.get(interaction.guild.id); - client.funcs.statisticsUpdate(client, interaction.guild, radio); + client.statistics.update(client, interaction.guild, radio); radio.connection?.destroy(); client.funcs.logger('Radio', interaction.guild.id + " / " + 'Stop'); From acc7ab1727f80b6127854056e5161eb42b318598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 04:52:41 +0300 Subject: [PATCH 081/105] Update ready event --- src/client/events/ready.js | 50 +++++++++++++------------------------- 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/src/client/events/ready.js b/src/client/events/ready.js index 6cbd876..368e60b 100644 --- a/src/client/events/ready.js +++ b/src/client/events/ready.js @@ -1,8 +1,8 @@ import Datastore from "../classes/Datastore.js"; import Radio from "../classes/Radio.js"; +import Stations from "../classes/Stations.js"; import Streamer from "../classes/Streamer.js"; -const _importDynamic = new Function('modulePath', 'return import(modulePath)'); -const fetch = (...args) => _importDynamic('node-fetch').then(({default: fetch}) => fetch(...args)); +import Statistics from "../classes/Statistics.js"; module.exports = { name: 'ready', @@ -39,42 +39,22 @@ module.exports = { console.log("\n"); /*STATIONS*/ - try { - client.funcs.logger('Stations', 'Started fetching list – ' + client.config.stationslistUrl); - client.stations = await fetch(client.config.stationslistUrl) - .then(client.funcs.checkFetchStatus) - .then(response => response.json()); + client.stations = new Stations(); - client.funcs.logger('Stations'); - client.stations.forEach(station => { - console.log("- " + station.name); - }); - console.log("\n"); - - client.funcs.logger('Stations', 'Successfully fetched list'); - } catch (error) { - client.funcs.logger('Stations', 'Fetching list failed'); - console.error(error + "\n"); - } + await client.stations.fetch({ + url: client.config.stationslistUrl + }); setInterval(async () => { - try { - client.funcs.logger('Stations', 'Started fetching list – ' + client.config.stationslistUrl); - client.stations = await fetch(client.config.stationslistUrl) - .then(client.funcs.checkFetchStatus) - .then(response => response.json()); - - client.funcs.logger('Stations', 'Successfully fetched list'); - } catch (error) { - client.funcs.logger('Stations', 'Fetching list failed'); - //console.error(error); - } + await client.stations.fetch({ + url: client.config.stationslistUrl + }); }, 3600000); client.streamer = new Streamer(); client.streamer.init(client); - if(!client.stations) { + if(!client.stations.list) { client.user.setStatus('dnd'); } @@ -91,7 +71,8 @@ module.exports = { client.funcs.logger('Guilds', 'Successfully fetched list'); /*STATISTICS*/ - client.datastore.calculateGlobal(client); + client.statistics = new Statistics(); + client.statistics.calculateGlobal(client); /*EMOJIS*/ require(`../emojis.js`).execute(client); @@ -99,13 +80,16 @@ module.exports = { /*COMMANDS*/ require(`../commands.js`).execute(client); + /*RADIO*/ + client.radio = new Radio(); + setTimeout(function () { /*RESTORE RADIOS*/ - client.funcs.restoreRadios(client, guilds); + client.radio.restore(client, guilds); }, 5000); setTimeout(function () { - if(client.stations) { + if(client.stations.list) { /*MAINTENANCE MODE*/ client.funcs.logger("Maintenance Mode", "Disabled"); client.config.maintenanceMode = false; From 1f4c3a08d00d1db4502e38d44bceffa7e3b24167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 04:52:56 +0300 Subject: [PATCH 082/105] Update SIGINT event --- src/client/events/SIGINT.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/events/SIGINT.js b/src/client/events/SIGINT.js index 1360c58..b7f11f1 100644 --- a/src/client/events/SIGINT.js +++ b/src/client/events/SIGINT.js @@ -4,7 +4,7 @@ module.exports = { client.user.setStatus('dnd'); client.streamer.leave(client); - client.funcs.saveRadios(client); + client.radio.save(client); setInterval(() => { if(client.radio.size == 0){ From 062a163a1191122d6bb88d1cbd6d0fd7f7881ecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 04:53:15 +0300 Subject: [PATCH 083/105] Update voiceStateUpdate event --- src/client/events/voiceStateUpdate.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/events/voiceStateUpdate.js b/src/client/events/voiceStateUpdate.js index 3eeb658..d180e2c 100644 --- a/src/client/events/voiceStateUpdate.js +++ b/src/client/events/voiceStateUpdate.js @@ -14,7 +14,7 @@ module.exports = { if (newState.member.id === client.user.id && oldState.member.id === client.user.id) { if (newState.channel === null) { - client.funcs.statisticsUpdate(client, newState.guild, radio); + client.statistics.update(client, newState.guild, radio); radio.connection?.destroy(); radio.message?.delete(); client.funcs.logger('Radio', newState.guild.id + " / " + 'Stop'); @@ -36,7 +36,7 @@ module.exports = { 1000 ); } catch (error) { - client.funcs.statisticsUpdate(client, newState.guild, radio); + client.statistics.update(client, newState.guild, radio); radio.connection?.destroy(); radio.message?.delete(); client.funcs.logger('Radio', newState.guild.id + " / " + 'Stop'); @@ -55,7 +55,7 @@ module.exports = { setTimeout(() => { if (!radio || !radio.connection || !radio.connection === null) return; if (radio.voiceChannel.members.size === 1) { - client.funcs.statisticsUpdate(client, newState.guild, radio); + client.statistics.update(client, newState.guild, radio); radio.connection?.destroy(); radio.message?.delete(); client.funcs.logger('Radio', newState.guild.id + " / " + 'Stop'); From 90c7c667e467e6e4ff6b98c5805ded5d84ff0db3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 04:53:31 +0300 Subject: [PATCH 084/105] Update check function --- src/client/funcs/check.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/funcs/check.js b/src/client/funcs/check.js index 4a5a216..50ef509 100644 --- a/src/client/funcs/check.js +++ b/src/client/funcs/check.js @@ -9,7 +9,7 @@ module.exports = function check(client, interaction, command) { }); return false; } - if(!client.stations) { + if(!client.stations.list) { message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild); interaction.reply({ content: client.messageEmojis["error"] + message.errorToGetPlaylist, From b34120e688b9edd7ae997a0064e41c12a12d08cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 04:53:48 +0300 Subject: [PATCH 085/105] Update listStations function --- src/client/funcs/listStations.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/funcs/listStations.js b/src/client/funcs/listStations.js index 2dd73db..be1dc2a 100644 --- a/src/client/funcs/listStations.js +++ b/src/client/funcs/listStations.js @@ -4,7 +4,7 @@ module.exports = function listStations(client, interaction){ let stations = new Array(); let options = new Array(); - stations = client.stations.forEach(station => { + stations = client.stations.list.forEach(station => { if(station.name == "GrooveFM") return; station = { label: station.name, From dbedb83104a567223572254ee35bb9cf83aac569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 05:13:07 +0300 Subject: [PATCH 086/105] Fix typo in Radio class --- src/client/classes/Radio.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/classes/Radio.js b/src/client/classes/Radio.js index 00d6bfc..2fbad38 100644 --- a/src/client/classes/Radio.js +++ b/src/client/classes/Radio.js @@ -51,7 +51,7 @@ module.exports = class Radio extends Map { message: null, station: station }; - this.list.set(guild.id, construct); + this.set(guild.id, construct); try { const connection = From ccb386e3b304ce79180ff401a5fc3d002dd6258f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 05:13:22 +0300 Subject: [PATCH 087/105] Update Stations class --- src/client/classes/Stations.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/client/classes/Stations.js b/src/client/classes/Stations.js index 4f9a631..aa3f444 100644 --- a/src/client/classes/Stations.js +++ b/src/client/classes/Stations.js @@ -1,9 +1,8 @@ const _importDynamic = new Function('modulePath', 'return import(modulePath)'); const fetch = (...args) => _importDynamic('node-fetch').then(({default: fetch}) => fetch(...args)); -module.exports = class { +module.exports = class Stations extends Array { constructor() { - this.list = new Array(); this.logger = require("../funcs/logger.js"); } @@ -14,15 +13,16 @@ module.exports = class { .then(this.checkFetchStatus) .then(response => response.json()); - if(!this.list){ + if(list){ this.logger('Stations'); - this.list.forEach(station => { + list.forEach(station => { console.log("- " + station.name); }); console.log("\n"); + + this = list; } - this.list = list; this.logger('Stations', 'Successfully fetched list'); } catch (error) { this.logger('Stations', 'Fetching list failed'); @@ -41,12 +41,12 @@ module.exports = class { } search(key) { - if (this.list === null) return false; + if (this === null) return false; let foundStations = []; if (!key) return false; if (key == "radio") return false; - this.list + this .filter( x => x.name.toUpperCase().includes(key.toUpperCase()) || x === key ) @@ -57,7 +57,7 @@ module.exports = class { if (key.startsWith("radio ")) key = key.slice(6); const probabilityIncrement = 100 / key.split(" ").length / 2; for (let i = 0; i < key.split(" ").length; i++) { - this.list + this .filter( x => x.name.toUpperCase().includes(key.split(" ")[i].toUpperCase()) || x === key ) From 4bf74f15a2d09b626473df08df1ce7c896cb17f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 05:16:41 +0300 Subject: [PATCH 088/105] Revert c7ddc6e --- src/client/commands/list.js | 4 ++-- src/client/commands/next.js | 6 +++--- src/client/commands/play.js | 4 ++-- src/client/commands/prev.js | 6 +++--- src/client/commands/statistics.js | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/client/commands/list.js b/src/client/commands/list.js index 00d73b9..70ba290 100644 --- a/src/client/commands/list.js +++ b/src/client/commands/list.js @@ -7,7 +7,7 @@ module.exports = { execute(interaction, client) { let message = {}; - if(!client.stations.list) { + if(!client.stations) { message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild); return interaction.reply({ content: client.messageEmojis["error"] + message.errorToGetPlaylist, @@ -20,7 +20,7 @@ module.exports = { if(radio && !client.config.maintenanceMode){ client.funcs.listStations(client, interaction); } else { - let stations = `${client.stations.list.map(s => `**#** ${s.name}`).join('\n')}` + let stations = `${client.stations.map(s => `**#** ${s.name}`).join('\n')}` const hashs = stations.split('**#**').length; for (let i = 0; i < hashs; i++) { stations = stations.replace('**#**', `**${i + 1}.**`); diff --git a/src/client/commands/next.js b/src/client/commands/next.js index 3f0114f..0712d74 100644 --- a/src/client/commands/next.js +++ b/src/client/commands/next.js @@ -6,10 +6,10 @@ module.exports = { if (client.funcs.check(client, interaction, command)) { const radio = client.radio.get(interaction.guild.id); - let index = client.stations.list.findIndex(station => station.name == radio.station.name) + 1; - if(index == client.stations.list.length) index = 0; + let index = client.stations.findIndex(station => station.name == radio.station.name) + 1; + if(index == client.stations.length) index = 0; - let station = client.stations.list[index]; + let station = client.stations[index]; if(!station) return interaction.reply({ content: client.messageEmojis["error"] + client.messages.noSearchResults, diff --git a/src/client/commands/play.js b/src/client/commands/play.js index 62b65a8..057aeaa 100644 --- a/src/client/commands/play.js +++ b/src/client/commands/play.js @@ -71,13 +71,13 @@ module.exports = { ephemeral: true }); } else if (!isNaN(number)) { - if (number > client.stations.list.length - 1) { + if (number > client.stations.length - 1) { return interaction.reply({ content: client.messageEmojis["error"] + client.messages.wrongStationNumber, ephemeral: true }); } else { - station = client.stations.list[number]; + station = client.stations[number]; } } else { if (query.length < 3) return interaction.reply({ diff --git a/src/client/commands/prev.js b/src/client/commands/prev.js index 6189919..75a79d0 100644 --- a/src/client/commands/prev.js +++ b/src/client/commands/prev.js @@ -6,10 +6,10 @@ module.exports = { if (client.funcs.check(client, interaction, command)) { const radio = client.radio.get(interaction.guild.id); - let index = client.stations.list.findIndex(station => station.name == radio.station.name) - 1; - if(index == -1) index = client.stations.list.length - 1; + let index = client.stations.findIndex(station => station.name == radio.station.name) - 1; + if(index == -1) index = client.stations.length - 1; - let station = client.stations.list[index]; + let station = client.stations[index]; if(!station) return interaction.reply({ content: client.messageEmojis["error"] + client.messages.noSearchResults, diff --git a/src/client/commands/statistics.js b/src/client/commands/statistics.js index 6c3f42b..56c533c 100644 --- a/src/client/commands/statistics.js +++ b/src/client/commands/statistics.js @@ -7,12 +7,12 @@ module.exports = { category: 'info', execute(interaction, client) { let message = {}; - let stations = client.stations.list; + let stations = client.stations; let currentGuild = client.datastore.getEntry(interaction.guild.id); let global = client.datastore.getEntry("global"); let statistics = ""; - if(!client.stations.list) { + if(!client.stations) { message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild); return interaction.reply({ content: client.messageEmojis["error"] + message.errorToGetPlaylist, From 5ee30b178241903620993e2a9dac75c29229b1d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 05:17:18 +0300 Subject: [PATCH 089/105] Update ready event --- src/client/events/ready.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/events/ready.js b/src/client/events/ready.js index 368e60b..1db73dc 100644 --- a/src/client/events/ready.js +++ b/src/client/events/ready.js @@ -54,7 +54,7 @@ module.exports = { client.streamer = new Streamer(); client.streamer.init(client); - if(!client.stations.list) { + if(!client.stations) { client.user.setStatus('dnd'); } From 9ecdbc2bee28e353a8da34136664affde447a28c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 05:17:33 +0300 Subject: [PATCH 090/105] Update check function --- src/client/funcs/check.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/funcs/check.js b/src/client/funcs/check.js index 50ef509..4a5a216 100644 --- a/src/client/funcs/check.js +++ b/src/client/funcs/check.js @@ -9,7 +9,7 @@ module.exports = function check(client, interaction, command) { }); return false; } - if(!client.stations.list) { + if(!client.stations) { message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild); interaction.reply({ content: client.messageEmojis["error"] + message.errorToGetPlaylist, From a8513ce51451fef48edd061a8469204a258743d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 05:17:47 +0300 Subject: [PATCH 091/105] Update listStations function --- src/client/funcs/listStations.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/funcs/listStations.js b/src/client/funcs/listStations.js index be1dc2a..2dd73db 100644 --- a/src/client/funcs/listStations.js +++ b/src/client/funcs/listStations.js @@ -4,7 +4,7 @@ module.exports = function listStations(client, interaction){ let stations = new Array(); let options = new Array(); - stations = client.stations.list.forEach(station => { + stations = client.stations.forEach(station => { if(station.name == "GrooveFM") return; station = { label: station.name, From f9d5be189e790359fa6a71b0a01d3eba8dfefd23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 05:34:52 +0300 Subject: [PATCH 092/105] Update Radio class --- src/client/classes/Radio.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/classes/Radio.js b/src/client/classes/Radio.js index 2fbad38..e639619 100644 --- a/src/client/classes/Radio.js +++ b/src/client/classes/Radio.js @@ -30,7 +30,7 @@ module.exports = class Radio extends Map { } restore(client, guilds) { - if(!client.stations.list) return; + if(!client.stations) return; guilds.forEach(async guild => { let state = client.funcs.loadState(client, guild); From ee0823212862a269e51d223f21012f32b11ffa22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 05:35:02 +0300 Subject: [PATCH 093/105] Update Stations class --- src/client/classes/Stations.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/client/classes/Stations.js b/src/client/classes/Stations.js index aa3f444..76493f5 100644 --- a/src/client/classes/Stations.js +++ b/src/client/classes/Stations.js @@ -3,6 +3,7 @@ const fetch = (...args) => _importDynamic('node-fetch').then(({default: fetch}) module.exports = class Stations extends Array { constructor() { + super(); this.logger = require("../funcs/logger.js"); } @@ -15,12 +16,15 @@ module.exports = class Stations extends Array { 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)]; + }); list.forEach(station => { console.log("- " + station.name); + this.push(station); }); console.log("\n"); - - this = list; } this.logger('Stations', 'Successfully fetched list'); From cc3b2a50cf4aa25ff0877e92745c43a0290ea27b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 05:35:12 +0300 Subject: [PATCH 094/105] Update Statistics class --- src/client/classes/Statistics.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/classes/Statistics.js b/src/client/classes/Statistics.js index 0387177..78bfac5 100644 --- a/src/client/classes/Statistics.js +++ b/src/client/classes/Statistics.js @@ -27,14 +27,14 @@ module.exports = class { } calculateGlobal(client){ - if(!client.stations.list) return; + if(!client.stations) return; if(!client.datastore.map) return; let guilds = client.datastore.map.keys(); - let stations = client.stations.list; + let stations = client.stations; let statistics = {}; - if(!client.stations.list) return; + if(!client.stations) return; let calculation = guilds.next(); From 214dff29d5e9b97ef7a6ac9f9f6e7f70b30c66ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 05:35:26 +0300 Subject: [PATCH 095/105] Update Streamer class --- src/client/classes/Streamer.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/client/classes/Streamer.js b/src/client/classes/Streamer.js index 895c6a3..5aacf9a 100644 --- a/src/client/classes/Streamer.js +++ b/src/client/classes/Streamer.js @@ -27,9 +27,9 @@ module.exports = class { } if(this.mode == "auto"){ - if(!client.stations.list) return; + if(!client.stations) return; - client.stations.list.forEach(station => { + client.stations.forEach(station => { this.play(station); }); } @@ -40,7 +40,7 @@ module.exports = class { let streamers = this.map.keys(); streamers.forEach(streamer => { - if(client.stations.list.findIndex(station => station.name == streamer)) return; + if(client.stations.findIndex(station => station.name == streamer)) return; this.stop(streamer); }); } @@ -119,9 +119,9 @@ module.exports = class { } leave(client) { - if(!client.stations.list) return; + if(!client.stations) return; - client.stations.list.forEach(station => { + client.stations.forEach(station => { this.stop(station); }); } From 0ee3ca5e08dbb488f778a940c3bdebf100437559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 05:35:40 +0300 Subject: [PATCH 096/105] Update ready event --- src/client/events/ready.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/events/ready.js b/src/client/events/ready.js index 1db73dc..8ffcd6e 100644 --- a/src/client/events/ready.js +++ b/src/client/events/ready.js @@ -89,7 +89,7 @@ module.exports = { }, 5000); setTimeout(function () { - if(client.stations.list) { + if(client.stations) { /*MAINTENANCE MODE*/ client.funcs.logger("Maintenance Mode", "Disabled"); client.config.maintenanceMode = false; From 8fc441c1b3a7f1b559cadea43975df86d4e86512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 05:41:59 +0300 Subject: [PATCH 097/105] Update play command --- src/client/commands/play.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/commands/play.js b/src/client/commands/play.js index 057aeaa..47cd34f 100644 --- a/src/client/commands/play.js +++ b/src/client/commands/play.js @@ -21,7 +21,7 @@ module.exports = { }); } - if(!client.stations.list) { + if(!client.stations) { message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild); return interaction.reply({ content: client.messageEmojis["error"] + message.errorToGetPlaylist, From ddff397fe4cdd9c21bd46fb1618fb196208f235d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 16 Sep 2021 08:03:10 +0000 Subject: [PATCH 098/105] Bump prettier from 2.4.0 to 2.4.1 Bumps [prettier](https://github.com/prettier/prettier) from 2.4.0 to 2.4.1. - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/2.4.0...2.4.1) --- updated-dependencies: - dependency-name: prettier dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index a65c950..3a0e64e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,7 +29,7 @@ "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", "nodemon": "^2.0.12", - "prettier": "^2.4.0", + "prettier": "^2.4.1", "rimraf": "^3.0.2", "ts-node": "^10.2.1", "tsc-watch": "^4.5.0", @@ -2929,9 +2929,9 @@ } }, "node_modules/prettier": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.4.0.tgz", - "integrity": "sha512-DsEPLY1dE5HF3BxCRBmD4uYZ+5DCbvatnolqTqcxEgKVZnL2kUfyu7b8pPQ5+hTBkdhU9SLUmK0/pHb07RE4WQ==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.4.1.tgz", + "integrity": "sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA==", "dev": true, "bin": { "prettier": "bin-prettier.js" @@ -6177,9 +6177,9 @@ "dev": true }, "prettier": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.4.0.tgz", - "integrity": "sha512-DsEPLY1dE5HF3BxCRBmD4uYZ+5DCbvatnolqTqcxEgKVZnL2kUfyu7b8pPQ5+hTBkdhU9SLUmK0/pHb07RE4WQ==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.4.1.tgz", + "integrity": "sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA==", "dev": true }, "prettier-linter-helpers": { diff --git a/package.json b/package.json index 90253ed..e88cfe4 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", "nodemon": "^2.0.12", - "prettier": "^2.4.0", + "prettier": "^2.4.1", "rimraf": "^3.0.2", "ts-node": "^10.2.1", "tsc-watch": "^4.5.0", From ead52decf25007dcfb8536e91a88a31a10498c31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 19:43:19 +0300 Subject: [PATCH 099/105] Update voiceStateUpdate event --- src/client/events/voiceStateUpdate.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/events/voiceStateUpdate.js b/src/client/events/voiceStateUpdate.js index d180e2c..8ae732e 100644 --- a/src/client/events/voiceStateUpdate.js +++ b/src/client/events/voiceStateUpdate.js @@ -51,17 +51,17 @@ module.exports = { //radio.connection = await newState.channel.join(); } } - if ((oldState.channel.members.size === 1 && oldState.channel === radio.voiceChannel) || change) { + if ((oldState.channel.members.filter(member => !member.user.bot).size === 0 && oldState.channel === radio.voiceChannel) || change) { setTimeout(() => { if (!radio || !radio.connection || !radio.connection === null) return; - if (radio.voiceChannel.members.size === 1) { + if (radio.voiceChannel.members.filter(member => !member.user.bot).size === 0) { client.statistics.update(client, newState.guild, radio); radio.connection?.destroy(); radio.message?.delete(); client.funcs.logger('Radio', newState.guild.id + " / " + 'Stop'); client.radio.delete(newState.guild.id); } - }, 60000); + }, 5000); } }, }; From 788216c3730c7b6f7d1a588a0a2e78b17a57dce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 19:43:40 +0300 Subject: [PATCH 100/105] Update Radio class --- src/client/classes/Radio.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/classes/Radio.js b/src/client/classes/Radio.js index e639619..ca0af5b 100644 --- a/src/client/classes/Radio.js +++ b/src/client/classes/Radio.js @@ -38,7 +38,7 @@ module.exports = class Radio extends Map { if(!state.station || !state.channels.voice || !state.channels.text) return; let voiceChannel = client.channels.cache.get(state.channels.voice); if(!voiceChannel) return; - if(voiceChannel.members.size === 0) return; + if(voiceChannel.members.filter(member => !member.user.bot).size === 0) return; const sstation = await client.stations.search(state.station.name); From b07f0d49426987c3dc8397e8b493a86e1661140d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Fri, 17 Sep 2021 12:44:55 +0300 Subject: [PATCH 101/105] Update Dependencies --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3a0e64e..d49e66c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -500,9 +500,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "16.9.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.1.tgz", - "integrity": "sha512-QpLcX9ZSsq3YYUUnD3nFDY8H7wctAhQj/TFKL8Ya8v5fMm3CFXxo8zStsLAl780ltoYoo1WvKUVGBQK+1ifr7g==" + "version": "16.9.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.2.tgz", + "integrity": "sha512-ZHty/hKoOLZvSz6BtP1g7tc7nUeJhoCf3flLjh8ZEv1vFKBWHXcnMbJMyN/pftSljNyy0kNW/UqI3DccnBnZ8w==" }, "node_modules/@types/ws": { "version": "7.4.7", @@ -4369,9 +4369,9 @@ "dev": true }, "@types/node": { - "version": "16.9.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.1.tgz", - "integrity": "sha512-QpLcX9ZSsq3YYUUnD3nFDY8H7wctAhQj/TFKL8Ya8v5fMm3CFXxo8zStsLAl780ltoYoo1WvKUVGBQK+1ifr7g==" + "version": "16.9.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.2.tgz", + "integrity": "sha512-ZHty/hKoOLZvSz6BtP1g7tc7nUeJhoCf3flLjh8ZEv1vFKBWHXcnMbJMyN/pftSljNyy0kNW/UqI3DccnBnZ8w==" }, "@types/ws": { "version": "7.4.7", From b38dfa039d5d1bf845c789ba1bdb11e39edb8aed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Fri, 17 Sep 2021 12:46:35 +0300 Subject: [PATCH 102/105] Update messages --- src/client/messages.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/messages.js b/src/client/messages.js index eb26915..b50f160 100644 --- a/src/client/messages.js +++ b/src/client/messages.js @@ -11,7 +11,7 @@ module.exports = { inviteTitle: "Invite %client.user.username% to your Discord server!", listTitle: "Radio Stations", nowplayingTitle: "Now Playing", - nowplayingDescription: "**%radio.station.name%**" + "\n" + "Owner: %radio.station.owner%" + "\n" + "%client.funcs.msToTime(completed)%", + nowplayingDescription: "**%radio.station.name%**" + "\n" + "%radio.station.owner%" + "\n" + "%client.funcs.msToTime(completed)%", noVoiceChannel: "You need to be in a voice channel to play radio!", noQuery: "You need to use a number or search for a supported station!", noPermsConnect: "I cannot connect to your voice channel.", From 7a8c10c6d43796a8fe2200e8db2592fd30165f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Fri, 17 Sep 2021 12:46:46 +0300 Subject: [PATCH 103/105] Update nowplaying command --- src/client/commands/nowplaying.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/client/commands/nowplaying.js b/src/client/commands/nowplaying.js index 1914c2d..46cda34 100644 --- a/src/client/commands/nowplaying.js +++ b/src/client/commands/nowplaying.js @@ -15,11 +15,7 @@ module.exports = { const completed = (radio.playTime); message.nowplayingDescription = client.messages.nowplayingDescription.replace("%radio.station.name%", radio.station.name); - if(radio.station.name != radio.station.owner){ - message.nowplayingDescription = message.nowplayingDescription.replace("%radio.station.owner%", radio.station.owner); - } else { - message.nowplayingDescription = message.nowplayingDescription.replace("%radio.station.owner%" + "\n", ""); - } + message.nowplayingDescription = message.nowplayingDescription.replace("%radio.station.owner%" + "\n", radio.station.name != radio.station.owner ? radio.station.owner + "\n" : ""); message.nowplayingDescription = message.nowplayingDescription.replace("%client.funcs.msToTime(completed)%", client.funcs.msToTime(completed)); const embed = new Discord.MessageEmbed() From f08eeb435c74eeef7b93e65fe82389f317ef584a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Fri, 17 Sep 2021 12:47:00 +0300 Subject: [PATCH 104/105] Update play function --- src/client/funcs/play.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/client/funcs/play.js b/src/client/funcs/play.js index 5d2cf19..992f3f1 100644 --- a/src/client/funcs/play.js +++ b/src/client/funcs/play.js @@ -8,13 +8,8 @@ module.exports = async function play(client, interaction, guild, station) { client.funcs.logger('Radio', guild.id + " / " + "Play" + " / " + radio.station.name); message.nowplayingDescription = client.messages.nowplayingDescription.replace("%radio.station.name%", radio.station.name); - if(radio.station.name != radio.station.owner){ - message.nowplayingDescription = message.nowplayingDescription.replace("%radio.station.owner%", radio.station.owner); - } else { - message.nowplayingDescription = message.nowplayingDescription.replace("%radio.station.owner%" + "\n", ""); - } + message.nowplayingDescription = message.nowplayingDescription.replace("%radio.station.owner%" + "\n", radio.station.name != radio.station.owner ? radio.station.owner + "\n" : ""); message.nowplayingDescription = message.nowplayingDescription.replace("%client.funcs.msToTime(completed)%", ""); - message.nowplayingDescription = message.nowplayingDescription.replace("Owner: ", ""); message.nowplayingDescription = message.nowplayingDescription.replace("**", ""); message.nowplayingDescription = message.nowplayingDescription.replace("**", ""); From b686afba983a327b424fe73d8e2395d6ed1fbcab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Fri, 17 Sep 2021 12:52:37 +0300 Subject: [PATCH 105/105] Update play function --- src/client/funcs/play.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/funcs/play.js b/src/client/funcs/play.js index 992f3f1..d369c1a 100644 --- a/src/client/funcs/play.js +++ b/src/client/funcs/play.js @@ -8,7 +8,7 @@ module.exports = async function play(client, interaction, guild, station) { client.funcs.logger('Radio', guild.id + " / " + "Play" + " / " + radio.station.name); message.nowplayingDescription = client.messages.nowplayingDescription.replace("%radio.station.name%", radio.station.name); - message.nowplayingDescription = message.nowplayingDescription.replace("%radio.station.owner%" + "\n", radio.station.name != radio.station.owner ? radio.station.owner + "\n" : ""); + message.nowplayingDescription = message.nowplayingDescription.replace("%radio.station.owner%", radio.station.name != radio.station.owner ? radio.station.owner + "\n" : ""); message.nowplayingDescription = message.nowplayingDescription.replace("%client.funcs.msToTime(completed)%", ""); message.nowplayingDescription = message.nowplayingDescription.replace("**", ""); message.nowplayingDescription = message.nowplayingDescription.replace("**", "");