mirror of
https://github.com/Ratstail91/SANCTUM.git
synced 2025-11-29 02:24:27 +11:00
71 lines
1.5 KiB
JavaScript
71 lines
1.5 KiB
JavaScript
// .env Variables
|
|
require('dotenv').config({path: '../.env'});
|
|
|
|
let shared = require("./shared.js");
|
|
|
|
let Discord = require("discord.js");
|
|
let client = new Discord.Client();
|
|
|
|
//message handler
|
|
client.on("ready", function() {
|
|
console.log("Logged in as " + client.user.tag);
|
|
});
|
|
|
|
client.on("reconnecting", function() {
|
|
console.log("Reconnecting...");
|
|
});
|
|
|
|
client.on("disconnect", function() {
|
|
console.log("Disconnected");
|
|
});
|
|
|
|
client.on("message", function(msg) {
|
|
//only react to commands
|
|
if (msg.content.slice(0, 1) !== process.env.PREFIX) {
|
|
return;
|
|
}
|
|
|
|
//get the command
|
|
let command = msg.content.slice(1).split(" ")[0];
|
|
let args = msg.content.slice(1 + command.length).trim();
|
|
|
|
//handle command
|
|
switch(command) {
|
|
//used for debugging
|
|
case "create":
|
|
shared.ChangeFaction(client, process.env.GROUP_A_ROLE, "bot-spam", msg.member);
|
|
break;
|
|
|
|
case "xp":
|
|
shared.AddXP(client, msg.author, parseInt(args));
|
|
break;
|
|
|
|
case "levelup":
|
|
shared.LevelUp(client, msg.member);
|
|
break;
|
|
|
|
case "rankup":
|
|
shared.RankUp(client, msg.member, parseInt(args));
|
|
break;
|
|
}
|
|
});
|
|
|
|
//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
|
|
client.login(process.env.DEVELOPER_TOKEN);
|
|
|
|
//TODO: change usernames to tags throughout the shared library
|
|
//FIXME: The server currently queries chest count, which is not in the database.
|
|
|