mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-12-23 01:13:17 +00:00
Added saveState & loadState functions
This commit is contained in:
parent
f2158ba8ae
commit
e546001be8
@ -37,6 +37,8 @@ class RadioClient extends Client {
|
||||
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");
|
||||
|
||||
console.log('RadioX ' + this.config.version);
|
||||
console.log('Internet Radio to your Discord guild');
|
||||
@ -53,7 +55,6 @@ class RadioClient extends Client {
|
||||
|
||||
this.on("ready", () => {
|
||||
require(`${events}ready`).execute(this);
|
||||
this.datastore = new Datastore();
|
||||
});
|
||||
|
||||
this.on("messageCreate", msg => {
|
||||
|
10
src/client/funcs/loadState.js
Normal file
10
src/client/funcs/loadState.js
Normal file
@ -0,0 +1,10 @@
|
||||
module.exports = function loadState(client, guild){
|
||||
let data = client.datastore.getEntry(guild.id);
|
||||
if(!data) return;
|
||||
let state;
|
||||
|
||||
state = data.state;
|
||||
data.state = {};
|
||||
client.datastore.updateEntry(guild, data);
|
||||
return state;
|
||||
}
|
18
src/client/funcs/saveState.js
Normal file
18
src/client/funcs/saveState.js
Normal file
@ -0,0 +1,18 @@
|
||||
module.exports = function saveState(client, guild, radio){
|
||||
client.datastore.checkEntry(guild.id);
|
||||
|
||||
let date = new Date();
|
||||
|
||||
let data = client.datastore.getEntry(guild.id);
|
||||
|
||||
data.state = {};
|
||||
data.state.channels = {};
|
||||
data.state.channels.text = radio.textChannel.id;
|
||||
data.state.channels.voice = radio.voiceChannel.id;
|
||||
data.state.date = date.toISOString();
|
||||
data.state.station = {};
|
||||
data.state.station.name = radio.station.name;
|
||||
data.state.station.owner = radio.station.owner;
|
||||
|
||||
client.datastore.updateEntry(guild, data);
|
||||
}
|
Loading…
Reference in New Issue
Block a user