mirror of
https://github.com/Ratstail91/SANCTUM.git
synced 2025-11-29 02:24:27 +11:00
Added a neat dialog generator utility
This commit is contained in:
@@ -50,8 +50,21 @@ client.on("message", function(msg) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//DEBUGGING
|
||||||
|
let dialogJson = {
|
||||||
|
"hello": [
|
||||||
|
"Hi there {1}!",
|
||||||
|
"Howdy {1}!"
|
||||||
|
],
|
||||||
|
"goodbye": "See ya!"
|
||||||
|
}
|
||||||
|
|
||||||
|
let dialog = shared.GenerateDialogFunction(dialogJson); //eventually be require("./dialog.json")
|
||||||
|
console.log(dialog("hello", "Kayne"));
|
||||||
|
|
||||||
//actually log in
|
//actually log in
|
||||||
client.login(process.env.DEVELOPER_TOKEN);
|
client.login(process.env.DEVELOPER_TOKEN);
|
||||||
|
|
||||||
//TODO: change usernames to tags throughout the shared library
|
//TODO: change usernames to tags throughout the shared library
|
||||||
//FIXME: The server currently queries chest count, which is not in the database.
|
//FIXME: The server currently queries chest count, which is not in the database.
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,25 @@ exports.CloneArray = function(arg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//GenerateDialogFunction
|
||||||
|
//dialogJson - the json object containing the bot's dialog
|
||||||
|
exports.GenerateDialogFunction = function(dialogJson) {
|
||||||
|
return function(key, data1 = "", data2 = "", data3 = "") {
|
||||||
|
let result;
|
||||||
|
|
||||||
|
if (Array.isArray(dialogJson[key])) {
|
||||||
|
result = dialogJson[key][Math.floor(Math.random() * dialogJson[key].length)];
|
||||||
|
} else {
|
||||||
|
result = dialogJson[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
.replace(/\{1\}/g, data1)
|
||||||
|
.replace(/\{2\}/g, data2)
|
||||||
|
.replace(/\{3\}/g, data3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//GetFooterCommands - Gets footer commands for botspam channel commands
|
//GetFooterCommands - Gets footer commands for botspam channel commands
|
||||||
//commandArray - the array of possible commands to use
|
//commandArray - the array of possible commands to use
|
||||||
//excludeCommand (optional) - the command to filter out
|
//excludeCommand (optional) - the command to filter out
|
||||||
|
|||||||
Reference in New Issue
Block a user