mirror of
https://github.com/Ratstail91/SANCTUM.git
synced 2025-11-29 02:24:27 +11:00
Uploaded bots for the first time
This commit is contained in:
27
modules/calcRandom.js
Normal file
27
modules/calcRandom.js
Normal file
@@ -0,0 +1,27 @@
|
||||
module.exports = {
|
||||
// Changed it from exclusive high to inclusive high
|
||||
random: function(low, high) {
|
||||
return Math.floor(Math.random() * (high - low + 1) + low);
|
||||
},
|
||||
|
||||
randomExc: function(low, high) {
|
||||
return Math.floor(Math.random() * (high - low) + low);
|
||||
},
|
||||
|
||||
// Random generation by %
|
||||
gamble: function(percentage) {
|
||||
// I found out that it wasn't acutally entirely accurate (0.1 difference)
|
||||
// So I changed it to be 1 to 100, and have a <= instead of <
|
||||
// I calculated it with PineTools and a small JS script to calculate it.
|
||||
// Feel free to change it!
|
||||
var winState = Math.floor(module.exports.random(1, 100));
|
||||
//var winState = Math.floor(module.exports.random(0, 101));
|
||||
|
||||
if (winState <= percentage) {
|
||||
// if (winState < percentage)
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
34
modules/channelProcessor.js
Normal file
34
modules/channelProcessor.js
Normal file
@@ -0,0 +1,34 @@
|
||||
require('dotenv').config({path: '../.env'});
|
||||
|
||||
module.exports = {
|
||||
isBotChannel: function(channelID) {
|
||||
// Insert new channels here
|
||||
var botChannels = [
|
||||
process.env.GROUP_A_BOT_ID,
|
||||
process.env.GROUP_B_BOT_ID,
|
||||
process.env.GROUP_C_BOT_ID,
|
||||
process.env.TEST_CHANNEL_ID
|
||||
];
|
||||
|
||||
// Apparently Outskirts was in the discord.io code, add that if needed
|
||||
|
||||
for (let index = 0; index < botChannels.length; index++) {
|
||||
const element = botChannels[index];
|
||||
if (channelID == element) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
isRaidChannel: function(channelID) {
|
||||
// Insert new channels here
|
||||
var raidChannels = [
|
||||
process.env.HELLS_GATE_CHANNEL_ID
|
||||
];
|
||||
|
||||
for (let index = 0; index < raidChannels.length; index++) {
|
||||
const element = raidChannels[index];
|
||||
if (channelID == element) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
29
modules/dataRequest.js
Normal file
29
modules/dataRequest.js
Normal file
@@ -0,0 +1,29 @@
|
||||
var request = require('sync-request');
|
||||
require('dotenv').config({path: '../.env'});
|
||||
|
||||
module.exports = {
|
||||
loadServerData: function(dataToLoad, usersID = ''){
|
||||
var res = request('GET', `http://skullboxstudios.com/projects/sanctum/botserver/getData.php?pk=${process.env.SERVER_PASS_KEY}&dataToLoad=` + dataToLoad + '&userid=' + usersID);
|
||||
console.log(res.getBody());
|
||||
return res.getBody();
|
||||
},
|
||||
|
||||
sendServerData: function(dataType, dataToSend, usersID = '', dataToSend2 = ''){
|
||||
var res = request('GET', `http://skullboxstudios.com/projects/sanctum/botserver/sendData.php?pk=${process.env.SERVER_PASS_KEY}&dataType=` + dataType + '&dataToSend=' + dataToSend + '&dataToSend2=' + dataToSend2 + '&userid=' + usersID);
|
||||
console.log(res.getBody());
|
||||
return res.getBody();
|
||||
},
|
||||
|
||||
sendAttackData: function(dataType, dataToSend, dataToSend2 = ''){
|
||||
var res = request('GET', `http://skullboxstudios.com/projects/sanctum/botserver/sendPostData.php?pk=${process.env.SERVER_PASS_KEY}&dataType=` + dataType + '&dataToSend=' + dataToSend + '&dataToSend2=' + dataToSend2)
|
||||
console.log(res.getBody());
|
||||
return res.getBody();
|
||||
},
|
||||
|
||||
// Possibly unused?
|
||||
postServerData: function(dataType, dataToPost, dataToSend2 = ''){
|
||||
var res = request('POST', `http://skullboxstudios.com/projects/sanctum/botserver/sendPostData.php?pk=${process.env.SERVER_PASS_KEY}&dataType=` + dataType + '&dataToSend2=' + dataToSend2, dataToPost)
|
||||
console.log(res.getBody());
|
||||
return res.getBody();
|
||||
}
|
||||
}
|
||||
20
modules/messages.js
Normal file
20
modules/messages.js
Normal file
@@ -0,0 +1,20 @@
|
||||
// Do not use, no client reference
|
||||
|
||||
module.exports = {
|
||||
sendMessage: function(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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user