mirror of
https://github.com/Ratstail91/SANCTUM.git
synced 2025-11-29 10:34:26 +11:00
Working the modules into Shared, untested
This commit is contained in:
13
ADAM/adam.js
13
ADAM/adam.js
@@ -2,15 +2,14 @@
|
||||
require('dotenv').config({path: '../.env'});
|
||||
|
||||
// Node Modules
|
||||
let Discord = require('discord.js');
|
||||
let client = new Discord.Client();
|
||||
let discord = require('discord.js');
|
||||
let client = new discord.Client();
|
||||
let cron = require('node-cron');
|
||||
|
||||
// Bot Modules
|
||||
let npcSettings = require('./npcSettings');
|
||||
let shared = require("../shared/shared");
|
||||
let core = require("./core");
|
||||
let dataRequest = require('../modules/dataRequest');
|
||||
let npcSettings = require('./npcSettings');
|
||||
let shared = require("../Shared/shared");
|
||||
|
||||
//dialog system
|
||||
let dialog = shared.GenerateDialogFunction(require("./dialog.json"));
|
||||
@@ -37,7 +36,7 @@ dialog = function(baseDialog) {
|
||||
//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
|
||||
// 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 () => {
|
||||
// Generates invite link
|
||||
try {
|
||||
@@ -63,7 +62,7 @@ client.on('ready', async () => {
|
||||
//ADAM updates stamina (1) and health by 1% every 2 min.
|
||||
cron.schedule('*/2 * * * *', () => {
|
||||
console.log('Updating STAMINA every 2 min.');
|
||||
dataRequest.sendServerData("updateStamina");
|
||||
shared.SendServerData("updateStamina");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
17
ADAM/core.js
17
ADAM/core.js
@@ -1,8 +1,9 @@
|
||||
exports = module.exports = {};
|
||||
|
||||
let Discord = require('discord.js');
|
||||
let shared = require("../shared/shared");
|
||||
let calcRandom = require('../modules/calcRandom');
|
||||
let dataRequest = require("../Shared/data_request");
|
||||
let discord = require('discord.js');
|
||||
let shared = require("../Shared/shared");
|
||||
let calcRandom = require('../Shared/calc_random');
|
||||
|
||||
//ProcessGameplayCommands
|
||||
//client - discord.js client
|
||||
@@ -17,7 +18,7 @@ exports.ProcessGameplayCommands = function(client, message, dialog) {
|
||||
switch (command) {
|
||||
case "checkin":
|
||||
let checkinAmount = calcRandom.random(4, 9);
|
||||
let checkInResponse = String(dataRequest.sendServerData("checkin", checkinAmount, message.author.id));
|
||||
let checkInResponse = String(dataRequest.SendServerData("checkin", message.author.id, checkinAmount));
|
||||
if (checkInResponse === "available") {
|
||||
shared.SendPublicMessage(client, message.author, message.channel, dialog("checkin", checkinAmount));
|
||||
shared.AddXP(client, message.author, 1); //1XP
|
||||
@@ -50,7 +51,7 @@ exports.ProcessGameplayCommands = function(client, message, dialog) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let accountBalance = dataRequest.loadServerData("account",message.author.id);
|
||||
let accountBalance = dataRequest.LoadServerData("account", message.author.id);
|
||||
|
||||
//not enough money in account
|
||||
if (accountBalance < amount) {
|
||||
@@ -59,7 +60,7 @@ exports.ProcessGameplayCommands = function(client, message, dialog) {
|
||||
}
|
||||
|
||||
//try to send the money
|
||||
if (dataRequest.sendServerData("transfer", targetMember.id, message.author.id, amount) != "success") {
|
||||
if (dataRequest.SendServerData("transfer", message.author.id, targetMember.id, amount) != "success") {
|
||||
shared.SendPublicMessage(client, message.channel, dialog("giveFailed", message.author.id));
|
||||
return true;
|
||||
}
|
||||
@@ -130,7 +131,7 @@ exports.GetStats = function(user) { //Grabs all parameters from server
|
||||
user = client.users.find(item => item.username === user || item.id === user);
|
||||
}
|
||||
|
||||
let userStatsResponse = String(dataRequest.loadServerData("userStats",user.id)).split(",");
|
||||
let userStatsResponse = String(dataRequest.LoadServerData("userStats", user.id)).split(",");
|
||||
|
||||
if (userStatsResponse[0] == "failure") {
|
||||
throw "server returned an error to userStats request";
|
||||
@@ -194,7 +195,7 @@ exports.PrintStats = function(client, member, channel, stats) {
|
||||
}
|
||||
|
||||
// Creates embed & sends it
|
||||
const embed = new Discord.RichEmbed()
|
||||
const embed = new discord.RichEmbed()
|
||||
.setAuthor(`${member.user.username}`, member.user.avatarURL)
|
||||
.setColor(member.displayColor)
|
||||
.setDescription(`${levelText} ${levelProgress} | ${crystalText} | ${cannisterText}`)
|
||||
|
||||
@@ -4,14 +4,17 @@
|
||||
"description": "",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "node adam.js"
|
||||
"start": "forever -o forever.log -e error.log start adam.js",
|
||||
"restart": "forever -o forever.log -e error.log restart adam.js",
|
||||
"stop": "forever stop adam.js",
|
||||
"node": "node adam.js"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"discord.js": "^11.4.2",
|
||||
"dotenv": "^6.0.0",
|
||||
"forever": "^0.15.3",
|
||||
"node-cron": "^1.2.1"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user