|
|
@ -9,6 +9,7 @@ exports.setLogger = function (newLogger) {
|
|
|
|
music.setLogger(logger);
|
|
|
|
music.setLogger(logger);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.GuildHandler = class {
|
|
|
|
exports.GuildHandler = class {
|
|
|
|
constructor(guild, prefix) {
|
|
|
|
constructor(guild, prefix) {
|
|
|
|
this.guild = guild;
|
|
|
|
this.guild = guild;
|
|
|
@ -20,22 +21,42 @@ exports.GuildHandler = class {
|
|
|
|
this.registerMusicCommands();
|
|
|
|
this.registerMusicCommands();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* function shortcut returns the data from the dataHandler
|
|
|
|
|
|
|
|
* @param name
|
|
|
|
|
|
|
|
* @returns {{}}
|
|
|
|
|
|
|
|
*/
|
|
|
|
getData(name) {
|
|
|
|
getData(name) {
|
|
|
|
return this.dataHandler.getData(name);
|
|
|
|
return this.dataHandler.getData(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* appends data to the data handler
|
|
|
|
|
|
|
|
* @param name
|
|
|
|
|
|
|
|
* @param key
|
|
|
|
|
|
|
|
* @param value
|
|
|
|
|
|
|
|
*/
|
|
|
|
appendData(name, key, value) {
|
|
|
|
appendData(name, key, value) {
|
|
|
|
let data = this.getData(name);
|
|
|
|
let data = this.getData(name);
|
|
|
|
data[key] = value;
|
|
|
|
data[key] = value;
|
|
|
|
this.dataHandler.setData(name, data);
|
|
|
|
this.dataHandler.setData(name, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* deletes an entry from the data handler
|
|
|
|
|
|
|
|
* @param name
|
|
|
|
|
|
|
|
* @param key
|
|
|
|
|
|
|
|
*/
|
|
|
|
deleteDataEntry(name, key) {
|
|
|
|
deleteDataEntry(name, key) {
|
|
|
|
let data = this.getData(name);
|
|
|
|
let data = this.getData(name);
|
|
|
|
delete data[key];
|
|
|
|
delete data[key];
|
|
|
|
this.dataHandler.setData(name, data);
|
|
|
|
this.dataHandler.setData(name, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* registers all music commands and initializes a dj
|
|
|
|
|
|
|
|
* @param cmdPrefix
|
|
|
|
|
|
|
|
*/
|
|
|
|
registerMusicCommands(cmdPrefix) {
|
|
|
|
registerMusicCommands(cmdPrefix) {
|
|
|
|
let prefix = cmdPrefix || this.prefix;
|
|
|
|
let prefix = cmdPrefix || this.prefix;
|
|
|
|
this.dj = new music.DJ();
|
|
|
|
this.dj = new music.DJ();
|
|
|
@ -170,11 +191,23 @@ exports.GuildHandler = class {
|
|
|
|
}, [], "Prints out all saved playlists.");
|
|
|
|
}, [], "Prints out all saved playlists.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* creates a servant if not set and lets the servant create a command
|
|
|
|
|
|
|
|
* @param command
|
|
|
|
|
|
|
|
* @param call
|
|
|
|
|
|
|
|
* @param args
|
|
|
|
|
|
|
|
* @param description
|
|
|
|
|
|
|
|
*/
|
|
|
|
createCommand(command, call, args, description) {
|
|
|
|
createCommand(command, call, args, description) {
|
|
|
|
if (!this.servant) this.servant = new cmd.Servant(this.prefix);
|
|
|
|
if (!this.servant) this.servant = new cmd.Servant(this.prefix);
|
|
|
|
this.servant.createCommand(command, call, args, description);
|
|
|
|
this.servant.createCommand(command, call, args, description);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* handles the message by letting the servant parse the command. Depending on the message setting it
|
|
|
|
|
|
|
|
* replies or just sends the answer.
|
|
|
|
|
|
|
|
* @param msg
|
|
|
|
|
|
|
|
*/
|
|
|
|
handleMessage(msg) {
|
|
|
|
handleMessage(msg) {
|
|
|
|
if (!this.servant) this.servant = new cmd.Servant(this.prefix);
|
|
|
|
if (!this.servant) this.servant = new cmd.Servant(this.prefix);
|
|
|
|
let answer = this.servant.parseCommand(msg);
|
|
|
|
let answer = this.servant.parseCommand(msg);
|
|
|
|