mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2025-07-01 15:43:38 +00:00
Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
3db736d3f3 | |||
22bb8c7467 | |||
12db2c5fcc | |||
51a038096a | |||
53fda7c401 | |||
a7f3029be0 | |||
9f373368b3 | |||
0945c7c26c | |||
871cb475f9 | |||
57aaf92947 | |||
dc7b14b11a | |||
0f5022df15 |
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "eximiabots-radiox",
|
||||
"version": "0.3.9",
|
||||
"version": "0.3.11",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "eximiabots-radiox",
|
||||
"version": "0.3.9",
|
||||
"version": "0.3.11",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@discordjs/builders": "^0.6.0",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "eximiabots-radiox",
|
||||
"version": "0.3.9",
|
||||
"version": "0.3.11",
|
||||
"description": "Internet Radio to your Discord guild",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
@ -48,8 +48,11 @@ module.exports = class {
|
||||
}
|
||||
|
||||
loadEntry(id){
|
||||
const json = require(`../../../datastore/` + id + '.json');
|
||||
this.map.set(id, json);
|
||||
try {
|
||||
const json = require(`../../../datastore/` + id + '.json');
|
||||
this.map.set(id, json);
|
||||
} catch (error) {
|
||||
}
|
||||
}
|
||||
|
||||
getEntry(id){
|
||||
|
@ -65,18 +65,8 @@ module.exports = class Radio extends Map {
|
||||
construct.connection = connection;
|
||||
let date = new Date();
|
||||
construct.startTime = date.getTime();
|
||||
|
||||
client.funcs.play(client, null, guild, station);
|
||||
|
||||
client.datastore.checkEntry(guild.id);
|
||||
construct.datastore = client.datastore.getEntry(guild.id);
|
||||
|
||||
if (!construct.datastore.statistics[construct.station.name]) {
|
||||
construct.datastore.statistics[construct.station.name] = {};
|
||||
construct.datastore.statistics[construct.station.name].time = 0;
|
||||
construct.datastore.statistics[construct.station.name].used = 0;
|
||||
client.datastore.updateEntry(guild, construct.datastore);
|
||||
}
|
||||
client.funcs.play(client, null, guild, station);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
@ -15,16 +15,18 @@ module.exports = class Stations extends Array {
|
||||
.then(response => response.json());
|
||||
|
||||
if(list){
|
||||
this.logger('Stations');
|
||||
this.forEach(oldStation => {
|
||||
if(list.findIndex(station => station.name == oldStation.name)) return;
|
||||
delete this[this.findIndex(station => station.name == oldStation.name)];
|
||||
});
|
||||
this.length = 0;
|
||||
list.forEach(station => {
|
||||
console.log("- " + station.name);
|
||||
this.push(station);
|
||||
});
|
||||
console.log("\n");
|
||||
|
||||
if(options.show){
|
||||
this.logger('Stations');
|
||||
list.forEach(station => {
|
||||
console.log("- " + station.name);
|
||||
});
|
||||
console.log("\n");
|
||||
}
|
||||
}
|
||||
|
||||
this.logger('Stations', 'Successfully fetched list');
|
||||
|
@ -40,8 +40,9 @@ module.exports = class {
|
||||
|
||||
let streamers = this.map.keys();
|
||||
streamers.forEach(streamer => {
|
||||
if(client.stations.findIndex(station => station.name == streamer)) return;
|
||||
this.stop(streamer);
|
||||
if(client.stations.findIndex(station => station.name == streamer) == -1){
|
||||
this.stop(streamer);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -73,15 +74,12 @@ module.exports = class {
|
||||
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");
|
||||
|
@ -155,7 +155,7 @@ module.exports = {
|
||||
client.config.maintenanceMode = true;
|
||||
|
||||
client.user.setStatus('idle');
|
||||
client.funcs.saveRadios(client);
|
||||
client.radio.save(client);
|
||||
|
||||
setInterval(() => {
|
||||
if(client.radio.size == 0 && client.config.streamerMode == "manual" && client.config.maintenanceMode){
|
||||
@ -179,7 +179,7 @@ module.exports = {
|
||||
client.config.maintenanceMode = true;
|
||||
|
||||
client.user.setStatus('idle');
|
||||
client.funcs.save(client);
|
||||
client.radio.save(client);
|
||||
|
||||
setInterval(() => {
|
||||
if(client.radio.size == 0 && client.config.streamerMode == "auto" && client.config.maintenanceMode){
|
||||
|
@ -42,12 +42,14 @@ module.exports = {
|
||||
client.stations = new Stations();
|
||||
|
||||
await client.stations.fetch({
|
||||
url: client.config.stationslistUrl
|
||||
url: client.config.stationslistUrl,
|
||||
show: true
|
||||
});
|
||||
|
||||
setInterval(async () => {
|
||||
await client.stations.fetch({
|
||||
url: client.config.stationslistUrl
|
||||
url: client.config.stationslistUrl,
|
||||
show: false
|
||||
});
|
||||
}, 3600000);
|
||||
|
||||
|
@ -4,6 +4,8 @@ module.exports = function loadState(client, guild){
|
||||
let state;
|
||||
|
||||
state = data.state;
|
||||
if(!state) return;
|
||||
|
||||
data.state = {};
|
||||
client.datastore.updateEntry(guild, data);
|
||||
return state;
|
||||
|
Reference in New Issue
Block a user