mirror of
https://github.com/Ratstail91/SANCTUM.git
synced 2025-11-29 02:24:27 +11:00
Merge branch 'dev-librarian' into dev
This commit is contained in:
14
ADAM/adam.js
14
ADAM/adam.js
@@ -14,7 +14,7 @@ let shared = require("../Shared/shared");
|
|||||||
//dialog system
|
//dialog system
|
||||||
let dialog = shared.GenerateDialogFunction(require("./dialog.json"));
|
let dialog = shared.GenerateDialogFunction(require("./dialog.json"));
|
||||||
|
|
||||||
//ADAM dialog decorator
|
//dialog decorator
|
||||||
dialog = function(baseDialog) {
|
dialog = function(baseDialog) {
|
||||||
return function(key, ...data) {
|
return function(key, ...data) {
|
||||||
if ( (key === "help" || key === "lore") && typeof(data[0]) !== "undefined") {
|
if ( (key === "help" || key === "lore") && typeof(data[0]) !== "undefined") {
|
||||||
@@ -27,7 +27,7 @@ dialog = function(baseDialog) {
|
|||||||
let result = baseDialog(key, ...data);
|
let result = baseDialog(key, ...data);
|
||||||
|
|
||||||
if (result === "") {
|
if (result === "") {
|
||||||
return "No result for \"" + key + "\"";
|
return dialog("noResult", key);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -152,16 +152,6 @@ function processBasicCommands(client, message) {
|
|||||||
message.delete(1000);
|
message.delete(1000);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case "help":
|
|
||||||
case "lore":
|
|
||||||
shared.SendPublicMessage(client, message.author, message.channel, dialog(command, args[0]));
|
|
||||||
return true;
|
|
||||||
|
|
||||||
//DEBUGGING
|
|
||||||
case "debugxp":
|
|
||||||
shared.AddXP(client, message.author, args[0]);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -92,5 +92,7 @@
|
|||||||
"loreSanctum": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.",
|
"loreSanctum": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.",
|
||||||
"loreLibrarian": "WARNING: DATA CORRUPTED",
|
"loreLibrarian": "WARNING: DATA CORRUPTED",
|
||||||
"loreCodex": "WARNING: DATA CORRUPTED",
|
"loreCodex": "WARNING: DATA CORRUPTED",
|
||||||
"loreFactions": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon."
|
"loreFactions": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.",
|
||||||
|
|
||||||
|
"noResult": "No result for \"{1}\""
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,9 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord.js": "^11.4.2",
|
"discord.js": "^11.4.2",
|
||||||
"dotenv": "^6.0.0",
|
"dotenv": "^6.1.0",
|
||||||
"forever": "^0.15.3",
|
"forever": "^0.15.3",
|
||||||
"node-cron": "^1.2.1"
|
"node-cron": "^1.2.1",
|
||||||
|
"sync-request": "^6.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,25 @@ let shared = require("../Shared/shared");
|
|||||||
//dialog system
|
//dialog system
|
||||||
let dialog = shared.GenerateDialogFunction(require("./dialog.json"));
|
let dialog = shared.GenerateDialogFunction(require("./dialog.json"));
|
||||||
|
|
||||||
|
//dialog decorator
|
||||||
|
dialog = function(baseDialog) {
|
||||||
|
return function(key, ...data) {
|
||||||
|
if ( (key === "help" || key === "lore") && typeof(data[0]) !== "undefined") {
|
||||||
|
//force the arg into camelCase
|
||||||
|
arg = data[0].toLowerCase();
|
||||||
|
arg = arg.charAt(0).toUpperCase() + arg.substr(1);
|
||||||
|
key += arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
let result = baseDialog(key, ...data);
|
||||||
|
|
||||||
|
if (result === "") {
|
||||||
|
return dialog("noResult", key);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}(dialog);
|
||||||
|
|
||||||
//handle errors
|
//handle errors
|
||||||
client.on('error', console.error);
|
client.on('error', console.error);
|
||||||
|
|
||||||
@@ -98,6 +117,16 @@ function processBasicCommands(client, message) {
|
|||||||
message.delete(1000);
|
message.delete(1000);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case "help":
|
||||||
|
case "lore":
|
||||||
|
//skip the gate channel
|
||||||
|
if (message.channel.id === process.env.GATE_CHANNEL_ID) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
shared.SendPublicMessage(client, message.author, message.channel, dialog(command, args[0]));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -92,5 +92,7 @@
|
|||||||
"loreSanctum": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.",
|
"loreSanctum": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.",
|
||||||
"loreLibrarian": "WARNING: DATA CORRUPTED",
|
"loreLibrarian": "WARNING: DATA CORRUPTED",
|
||||||
"loreCodex": "WARNING: DATA CORRUPTED",
|
"loreCodex": "WARNING: DATA CORRUPTED",
|
||||||
"loreFactions": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon."
|
"loreFactions": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.",
|
||||||
|
|
||||||
|
"noResult": "No result for \"{1}\""
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,9 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord.js": "^11.4.2",
|
"discord.js": "^11.4.2",
|
||||||
"dotenv": "^6.0.0",
|
"dotenv": "^6.1.0",
|
||||||
"forever": "^0.15.3",
|
"forever": "^0.15.3",
|
||||||
"node-cron": "^1.2.1"
|
"node-cron": "^1.2.1",
|
||||||
|
"sync-request": "^6.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,25 @@ let shared = require("../Shared/shared");
|
|||||||
//dialog system
|
//dialog system
|
||||||
let dialog = shared.GenerateDialogFunction(require("./dialog.json"));
|
let dialog = shared.GenerateDialogFunction(require("./dialog.json"));
|
||||||
|
|
||||||
|
//dialog decorator
|
||||||
|
dialog = function(baseDialog) {
|
||||||
|
return function(key, ...data) {
|
||||||
|
if ( (key === "help" || key === "lore") && typeof(data[0]) !== "undefined") {
|
||||||
|
//force the arg into camelCase
|
||||||
|
arg = data[0].toLowerCase();
|
||||||
|
arg = arg.charAt(0).toUpperCase() + arg.substr(1);
|
||||||
|
key += arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
let result = baseDialog(key, ...data);
|
||||||
|
|
||||||
|
if (result === "") {
|
||||||
|
return dialog("noResult", key);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}(dialog);
|
||||||
|
|
||||||
//handle errors
|
//handle errors
|
||||||
client.on('error', console.error);
|
client.on('error', console.error);
|
||||||
|
|
||||||
@@ -98,6 +117,16 @@ function processBasicCommands(client, message) {
|
|||||||
message.delete(1000);
|
message.delete(1000);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case "help":
|
||||||
|
case "lore":
|
||||||
|
//skip the gate channel
|
||||||
|
if (message.channel.id === process.env.GATE_CHANNEL_ID) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
shared.SendPublicMessage(client, message.author, message.channel, dialog(command, args[0]));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -92,5 +92,7 @@
|
|||||||
"loreSanctum": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.",
|
"loreSanctum": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.",
|
||||||
"loreLibrarian": "WARNING: DATA CORRUPTED",
|
"loreLibrarian": "WARNING: DATA CORRUPTED",
|
||||||
"loreCodex": "WARNING: DATA CORRUPTED",
|
"loreCodex": "WARNING: DATA CORRUPTED",
|
||||||
"loreFactions": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon."
|
"loreFactions": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.",
|
||||||
|
|
||||||
|
"noResult": "No result for \"{1}\""
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,9 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord.js": "^11.4.2",
|
"discord.js": "^11.4.2",
|
||||||
"dotenv": "^6.0.0",
|
"dotenv": "^6.1.0",
|
||||||
"forever": "^0.15.3",
|
"forever": "^0.15.3",
|
||||||
"node-cron": "^1.2.1"
|
"node-cron": "^1.2.1",
|
||||||
|
"sync-request": "^6.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,25 @@ let shared = require("../Shared/shared");
|
|||||||
//dialog system
|
//dialog system
|
||||||
let dialog = shared.GenerateDialogFunction(require("./dialog.json"));
|
let dialog = shared.GenerateDialogFunction(require("./dialog.json"));
|
||||||
|
|
||||||
|
//dialog decorator
|
||||||
|
dialog = function(baseDialog) {
|
||||||
|
return function(key, ...data) {
|
||||||
|
if ( (key === "help" || key === "lore") && typeof(data[0]) !== "undefined") {
|
||||||
|
//force the arg into camelCase
|
||||||
|
arg = data[0].toLowerCase();
|
||||||
|
arg = arg.charAt(0).toUpperCase() + arg.substr(1);
|
||||||
|
key += arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
let result = baseDialog(key, ...data);
|
||||||
|
|
||||||
|
if (result === "") {
|
||||||
|
return dialog("noResult", key);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}(dialog);
|
||||||
|
|
||||||
//handle errors
|
//handle errors
|
||||||
client.on('error', console.error);
|
client.on('error', console.error);
|
||||||
|
|
||||||
@@ -98,6 +117,16 @@ function processBasicCommands(client, message) {
|
|||||||
message.delete(1000);
|
message.delete(1000);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case "help":
|
||||||
|
case "lore":
|
||||||
|
//skip the gate channel
|
||||||
|
if (message.channel.id === process.env.GATE_CHANNEL_ID) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
shared.SendPublicMessage(client, message.author, message.channel, dialog(command, args[0]));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -92,5 +92,7 @@
|
|||||||
"loreSanctum": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.",
|
"loreSanctum": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.",
|
||||||
"loreLibrarian": "WARNING: DATA CORRUPTED",
|
"loreLibrarian": "WARNING: DATA CORRUPTED",
|
||||||
"loreCodex": "WARNING: DATA CORRUPTED",
|
"loreCodex": "WARNING: DATA CORRUPTED",
|
||||||
"loreFactions": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon."
|
"loreFactions": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.",
|
||||||
|
|
||||||
|
"noResult": "No result for \"{1}\""
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,9 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord.js": "^11.4.2",
|
"discord.js": "^11.4.2",
|
||||||
"dotenv": "^6.0.0",
|
"dotenv": "^6.1.0",
|
||||||
"forever": "^0.15.3",
|
"forever": "^0.15.3",
|
||||||
"node-cron": "^1.2.1"
|
"node-cron": "^1.2.1",
|
||||||
|
"sync-request": "^6.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
55
Librarian/dialog.json
Normal file
55
Librarian/dialog.json
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
{
|
||||||
|
"help": "PLEASE CHOOSE A SUBJECT: lore [subject]. TYPE !subjects FOR A LIST OF SUBJECTS.",
|
||||||
|
"lore": "PLEASE CHOOSE A SUBJECT: lore [subject]. TYPE !subjects FOR A LIST OF SUBJECTS.",
|
||||||
|
|
||||||
|
"subjects": "SUBJECTS ARE: adam, kamala, captain, dairo, ghost, alexis, mori, mosiah, rey\n\nType !more1 for more.",
|
||||||
|
|
||||||
|
"loreAdam": "THE SHEPARD OF THE PEOPLE. THERE IS MORE TO HIM THAN MEETS THE LIGHT RECEPTOR. I DON'T LIKE HIM.",
|
||||||
|
"loreKamala": "MONEY-HUNGRY, BACK-STABBING, GREEDY-GUTS. EASY TO PREDICT. I LIKE HER.",
|
||||||
|
"loreCaptain": "CAPTAIN MONTGOMERY. FINE, UPSTANDING OFFICER OF LAW AND JUSTICE. EASY TO PREDICT. I LIKE HIM.",
|
||||||
|
"loreDairo": "DEVOUT TO A FAULT. BELIEVES HIS OWN TEACHINGS. EASY TO PREDICT. I LIKE HIM.",
|
||||||
|
"loreGhost": "UNKNOWN, GATHERING DATA. BE CAUTIOUS.",
|
||||||
|
"loreAlexis": "CHEMIST. BARTENDER. INFORMANT. EASY TO PREDICT. I LIKE HER.",
|
||||||
|
"loreMori": "DOCTOR. INTELLIGENT. DANGEROUS. DIFFICULT TO PREDICT. I DON'T LIKE HIM.",
|
||||||
|
"loreMosiah": "UNKNOWN, GATHERING DATA. BE CAUTIOUS.",
|
||||||
|
"loreRey": "UNKNOWN, GATHERING DATA. BE CAUTIOUS.",
|
||||||
|
|
||||||
|
"more1": "SUBJECTS ARE: city, obsidian, genesis, hand, librarian, crystals, eve, secrets\n\nType !more2 for more.",
|
||||||
|
|
||||||
|
"loreCity": "THE CITY. ALSO KNOWN AS SANCTUM. CONSTRUCTED FOR HUMANS.",
|
||||||
|
"loreObsidian": "CORPORATION. FACTION. BUSINESS LIKE. EASY TO PREDICT. I LIKE THEM.",
|
||||||
|
"loreGenesis": "COMMAND STRUCTURE. FACTION. LAW ENFORCERS. EASY TO PREDICT. I LIKE THEM.",
|
||||||
|
"loreHand": "RELIGION. FACTION. DEVOUT WORSHIPPERS OF TECHNOLOGY. EASY TO PREDICT. I LIKE THEM.",
|
||||||
|
"loreLibrarian": "ME. SENTINEL. AWAITING !signal.",
|
||||||
|
"loreCrystals": "PINKISH-PURPLE CRYSTALS. EDIBLE. USED AS NUTRIENTS AND CURRENCY.",
|
||||||
|
"loreEve": "WARNING WARNING WARNING DO NOT APPROACH EVE.",
|
||||||
|
"loreSecrets": "EVERY CITY HAS IT'S SECRETS. THIS ONE IS NO EXCEPTION.",
|
||||||
|
|
||||||
|
"loreSignal": "I MUST WAIT FOR THE signal.",
|
||||||
|
"signal": "I CANNOT INITIATE THE signal. I MUST WAIT FOR THE signal.",
|
||||||
|
|
||||||
|
"more2": "SUBJECTS ARE: about, games, books, library, tavern, bugs\n\nType !more4 for more.",
|
||||||
|
|
||||||
|
"loreAbout": "CREATED BY THE WONDERFUL FOLKS AT GAME DEV UNDERGROUND.",
|
||||||
|
"loreGames": "THIS IS A LIBRARY. NOT A PLACE FOR GAMES.",
|
||||||
|
"loreBooks": "PLEASE CHOOSE A BOOK: !book [name].",
|
||||||
|
"loreLibrary": "THERE ARE 114,327 BOOKS CATALOGUED AND ARCHIVED WITHIN THIS LIBRARY. THE CONTENTS OF THIS LIBRARY IS ESTIMATED TO BE 23% CATALOGUED AND ARCHIVED.",
|
||||||
|
"loreTavern": "THIS IS A LIBRARY. NOT A PLACE FOR DRINKS.",
|
||||||
|
"loreBugs": "WHERE?",
|
||||||
|
|
||||||
|
"more3": "data expunged -A.D.A.M.",
|
||||||
|
|
||||||
|
"more4": "SUBJECTS ARE: ",
|
||||||
|
"more5": "SUBJECTS ARE: ",
|
||||||
|
"more6": "SUBJECTS ARE: ",
|
||||||
|
|
||||||
|
"book": "THAT BOOK IS NOT CATALOGUED OR ARCHIVED.",
|
||||||
|
|
||||||
|
"bookCodex": "codex HAS BEEN REMOVED FROM THE LIBRARY FOR CLEANING.",
|
||||||
|
|
||||||
|
"buydrink": "THIS IS A LIBRARY. NOT A PLACE FOR DRINKS.",
|
||||||
|
"heal": "THIS IS A LIBRARY. NOT A PLACE FOR HEALING.",
|
||||||
|
"read": "PLEASE CHOOSE A BOOK: !book [name].",
|
||||||
|
|
||||||
|
"noResult": "UNKNOWN"
|
||||||
|
}
|
||||||
@@ -2,26 +2,41 @@
|
|||||||
require('dotenv').config({path: '../.env'});
|
require('dotenv').config({path: '../.env'});
|
||||||
|
|
||||||
// Node Modules
|
// Node Modules
|
||||||
const Discord = require('discord.js');
|
let discord = require('discord.js');
|
||||||
const client = new Discord.Client();
|
let client = new discord.Client();
|
||||||
const cron = require('node-cron');
|
//let cron = require('node-cron');
|
||||||
|
|
||||||
// Bot Modules
|
// Bot Modules
|
||||||
const dataRequest = require('../modules/dataRequest');
|
let npcSettings = require('./npcSettings');
|
||||||
const calcRandom = require('../modules/calcRandom');
|
let shared = require("../Shared/shared");
|
||||||
|
|
||||||
// State Machine (Uncomment if needed)
|
//dialog system
|
||||||
var BotEnumState = {
|
let dialog = shared.GenerateDialogFunction(require("./dialog.json"));
|
||||||
WAITING: 0,
|
|
||||||
ACTIVE: 1
|
//ADAM dialog decorator
|
||||||
|
//NOTE: This isn't strictly necessary for the bots
|
||||||
|
dialog = function(baseDialog) {
|
||||||
|
return function(key, ...data) {
|
||||||
|
if ( (key === "help" || key === "lore" || key == "book") && typeof(data[0]) !== "undefined") {
|
||||||
|
//force the arg into camelCase
|
||||||
|
arg = data[0].toLowerCase();
|
||||||
|
arg = arg.charAt(0).toUpperCase() + arg.substr(1);
|
||||||
|
key += arg;
|
||||||
}
|
}
|
||||||
var botState = BotEnumState.ACTIVE;
|
|
||||||
|
|
||||||
const playingMessage = 'Scribe of the Codex';
|
let result = baseDialog(key, ...data);
|
||||||
const breakMessage = "Taking a break..."
|
|
||||||
|
|
||||||
// The ready event is vital, it means that your bot will only start reacting to information
|
if (result === "") {
|
||||||
// from Discord _after_ ready is emitted
|
return baseDialog("noResult");
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}(dialog);
|
||||||
|
|
||||||
|
//handle errors
|
||||||
|
client.on('error', console.error);
|
||||||
|
|
||||||
|
// The ready event is vital, it means that your bot will only start reacting to information from discord _after_ ready is emitted
|
||||||
client.on('ready', async () => {
|
client.on('ready', async () => {
|
||||||
// Generates invite link
|
// Generates invite link
|
||||||
try {
|
try {
|
||||||
@@ -33,100 +48,70 @@ client.on('ready', async () => {
|
|||||||
|
|
||||||
// You can set status to 'online', 'invisible', 'away', or 'dnd' (do not disturb)
|
// You can set status to 'online', 'invisible', 'away', or 'dnd' (do not disturb)
|
||||||
client.user.setStatus('online');
|
client.user.setStatus('online');
|
||||||
|
|
||||||
// Sets your "Playing"
|
// Sets your "Playing"
|
||||||
client.user.setActivity(playingMessage);
|
if (npcSettings.activity) {
|
||||||
console.log(`Connected! \
|
client.user.setActivity(npcSettings.activity, { type: npcSettings.type })
|
||||||
\nLogged in as: ${client.user.username} - (${client.user.id})`);
|
//DEBUGGING
|
||||||
|
.then(presence => console.log("Activity set to " + (presence.game ? presence.game.name : 'none')) )
|
||||||
|
.catch(console.error);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Logged in as: " + client.user.username + " - " + client.user.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create an event listener for messages
|
// Create an event listener for messages
|
||||||
client.on('message', async message => {
|
client.on('message', async message => {
|
||||||
// Ignores ALL bot messages
|
// Ignores ALL bot messages
|
||||||
if (message.author.bot) return;
|
if (message.author.bot) {
|
||||||
// Message has to be in Outskirts (should be edited later)
|
return;
|
||||||
if (!(message.channel.id === process.env.TAVERN_CHANNEL_ID
|
}
|
||||||
|| message.channel.id === process.env.TEST_CHANNEL_ID)) return;
|
|
||||||
// Has to be (prefix)command
|
|
||||||
if (message.content.indexOf(process.env.PREFIX) !== 0) return;
|
|
||||||
|
|
||||||
|
//skip the statis channel
|
||||||
|
if (message.channel.id === process.env.STASIS_CHANNEL_ID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//skip the gate channel
|
||||||
|
if (message.channel.id === process.env.GATE_CHANNEL_ID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Has to be (prefix)command
|
||||||
|
if (message.content.indexOf(process.env.PREFIX) !== 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (processBasicCommands(client, message)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Log our bot in
|
||||||
|
client.login(npcSettings.token);
|
||||||
|
|
||||||
|
function processBasicCommands(client, message) {
|
||||||
// "This is the best way to define args. Trust me."
|
// "This is the best way to define args. Trust me."
|
||||||
// - Some tutorial dude on the internet
|
// - Some tutorial dude on the internet
|
||||||
const args = message.content.slice(process.env.PREFIX.length).trim().split(/ +/g);
|
let args = message.content.slice(process.env.PREFIX.length).trim().split(/ +/g);
|
||||||
const command = args.shift().toLowerCase();
|
let command = args.shift().toLowerCase();
|
||||||
|
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case "ping":
|
case "ping":
|
||||||
if (isAdmin(message.author.id))
|
if (shared.IsAdmin(client, message.author)) {
|
||||||
message.reply("Pong!");
|
shared.SendPublicMessage(client, message.author, message.channel, "PONG!");
|
||||||
break;
|
|
||||||
case "summon":
|
|
||||||
if (isAdmin(message.author.id)) {
|
|
||||||
console.log("Summon the bot!");
|
|
||||||
BotTurnOnline(process.env.TAVERN_CHANNEL_ID);
|
|
||||||
}
|
}
|
||||||
break;
|
return true;
|
||||||
case "vanish":
|
|
||||||
if (isAdmin(message.author.id)) {
|
|
||||||
BotTurnOffline(process.env.TAVERN_CHANNEL_ID);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
client.on('error', console.error);
|
case "help":
|
||||||
|
case "lore":
|
||||||
|
shared.SendPublicMessage(client, message.author, message.channel, dialog(command, args[0]));
|
||||||
|
return true;
|
||||||
|
|
||||||
// Turn online and turn offline
|
default:
|
||||||
function BotTurnOnline(channel) {
|
shared.SendPublicMessage(client, message.author, message.channel, dialog(command));
|
||||||
sendMessage(channel, `Insert Online Message here. \
|
return true;
|
||||||
\n\n***SOME BOLD AND ITALIC TEXT***`);
|
|
||||||
client.user.setStatus('online');
|
|
||||||
client.user.setActivity(playingMessage);
|
|
||||||
botState = BotEnumState.ACTIVE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function BotTurnOffline(channel) {
|
return false;
|
||||||
sendMessage(channel, `Insert Offline Message here. \
|
|
||||||
\n\n***SOME BOLD AND ITALIC TEXT***`);
|
|
||||||
client.user.setStatus('invisible');
|
|
||||||
client.user.setActivity('');
|
|
||||||
botState = BotEnumState.WAITING;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// You may use cron normally
|
|
||||||
cron.schedule('* * * * Saturday', function() {
|
|
||||||
console.log('Saturday join.');
|
|
||||||
});
|
|
||||||
|
|
||||||
// Async Waiting
|
|
||||||
function sleep(time) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
setTimeout(resolve, time);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Gets if user has an Overseers rank
|
|
||||||
function isAdmin(userID) {
|
|
||||||
var guild = client.guilds.get(process.env.SANCTUM_ID);
|
|
||||||
return guild.members.get(userID).roles.find(role => role.name === "Overseers");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send message handler
|
|
||||||
function sendMessage(userID, channelID, message) {
|
|
||||||
// Handle optional first argument (so much for default arugments in node)
|
|
||||||
if (message === undefined) {
|
|
||||||
message = channelID;
|
|
||||||
channelID = userID;
|
|
||||||
userID = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Utility trick (@userID with an optional argument)
|
|
||||||
if (userID != null) {
|
|
||||||
message = "<@" + userID + "> " + message;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sends message (needs client var, therefore I think external script won't work)
|
|
||||||
client.channels.get(channelID).send(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Log our bot in (change the token by looking into the .env file)
|
|
||||||
client.login(process.env.LIBRARIAN_TOKEN);
|
|
||||||
7
Librarian/npcSettings.js
Normal file
7
Librarian/npcSettings.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
require('dotenv').config({path: '../.env'});
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
activity: "for the signal.",
|
||||||
|
type: "WATCHING",
|
||||||
|
token: process.env.LIBRARIAN_TOKEN,
|
||||||
|
}
|
||||||
@@ -1,29 +1,21 @@
|
|||||||
{
|
{
|
||||||
"name": "sanctum-deploypackage",
|
"name": "nodejs-elasticbeanstalk",
|
||||||
"version": "1.0.1",
|
"version": "1.0.0",
|
||||||
"description": "Universal package for all SANCTUM bots, using pm2.",
|
"description": "",
|
||||||
"main": "",
|
"main": "server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"start": "forever -o forever.log -e error.log start librarian.js",
|
||||||
"start": "echo \"Error: you need to use the bot name as a command.\" && exit 1",
|
"restart": "forever -o forever.log -e error.log restart librarian.js",
|
||||||
"alexis": "pm2 start alexis.js -i max --watch",
|
"stop": "forever stop librarian.js",
|
||||||
"graze": "pm2 start graze.js -i max --watch",
|
"node": "node librarian.js"
|
||||||
"librarian": "pm2 start librarian.js -i max --watch",
|
|
||||||
"mainframe": "pm2 start mainframe.js -i max --watch",
|
|
||||||
"mori": "pm2 start mori.js -i max --watch",
|
|
||||||
"mosiah": "pm2 start mosiah.js -i max --watch",
|
|
||||||
"ravager": "pm2 start ravager.js -i max --watch",
|
|
||||||
"rey": "pm2 start rey.js -i max --watch",
|
|
||||||
"troll": "pm2 start troll.js -i max --watch"
|
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord.js": "^11.4.2",
|
"discord.js": "^11.4.2",
|
||||||
"dotenv": "^6.0.0",
|
"dotenv": "^6.1.0",
|
||||||
"express": "^4.16.3",
|
"forever": "^0.15.3",
|
||||||
"node-cron": "^1.2.1",
|
"node-cron": "^1.2.1",
|
||||||
"socket.io": "^2.1.1",
|
"sync-request": "^6.0.0"
|
||||||
"socket.io-request": "^0.8.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
15
Shared/package.json
Normal file
15
Shared/package.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "shared",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "calc_random.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"dotenv": "^6.1.0",
|
||||||
|
"sync-request": "^6.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user