mirror of
https://github.com/Ratstail91/SANCTUM.git
synced 2025-11-29 02:24:27 +11:00
Created empty Graze
This commit is contained in:
91
BOT_Graze/bot-graze.js
Normal file
91
BOT_Graze/bot-graze.js
Normal file
@@ -0,0 +1,91 @@
|
||||
// .env Variables
|
||||
require('dotenv').config({path: '../.env'});
|
||||
|
||||
// Node Modules
|
||||
let discord = require('discord.js');
|
||||
let client = new discord.Client();
|
||||
|
||||
// Bot Modules
|
||||
let npcSettings = require('./npcSettings');
|
||||
let shared = require("../Shared/shared");
|
||||
|
||||
//dialog system
|
||||
let dialog = shared.GenerateDialogFunction(require("./dialog.json"));
|
||||
|
||||
//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 () => {
|
||||
// Generates invite link
|
||||
try {
|
||||
let link = await client.generateInvite(["ADMINISTRATOR"]);
|
||||
console.log("Invite Link: " + link);
|
||||
} catch(e) {
|
||||
console.log(e.stack);
|
||||
}
|
||||
|
||||
// You can set status to 'online', 'invisible', 'away', or 'dnd' (do not disturb)
|
||||
client.user.setStatus('online');
|
||||
|
||||
// Sets your "Playing"
|
||||
if (npcSettings.activity) {
|
||||
client.user.setActivity(npcSettings.activity, { type: npcSettings.type })
|
||||
//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
|
||||
client.on('message', async message => {
|
||||
// Ignores ALL bot messages
|
||||
if (message.author.bot) {
|
||||
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."
|
||||
// - Some tutorial dude on the internet
|
||||
let args = message.content.slice(process.env.PREFIX.length).trim().split(/ +/g);
|
||||
let command = args.shift().toLowerCase();
|
||||
|
||||
switch (command) {
|
||||
case "ping":
|
||||
if (shared.IsAdmin(client, message.author)) {
|
||||
shared.SendPublicMessage(client, message.author, message.channel, "PONG!");
|
||||
}
|
||||
return true;
|
||||
|
||||
default:
|
||||
shared.SendPublicMessage(client, message.author, message.channel, dialog(command));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
3
BOT_Graze/dialog.json
Normal file
3
BOT_Graze/dialog.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"noResult": "I have no idea what you just said."
|
||||
}
|
||||
7
BOT_Graze/npcSettings.js
Normal file
7
BOT_Graze/npcSettings.js
Normal file
@@ -0,0 +1,7 @@
|
||||
require('dotenv').config({path: '../.env'});
|
||||
|
||||
module.exports = {
|
||||
activity: "for upgrade requests.",
|
||||
type: "WATCHING",
|
||||
token: process.env.GRAZE_TOKEN,
|
||||
}
|
||||
20
BOT_Graze/package.json
Normal file
20
BOT_Graze/package.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "Librarian",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"start": "forever -o forever.log -e error.log start bot-graze.js",
|
||||
"restart": "forever -o forever.log -e error.log restart bot-graze.js",
|
||||
"stop": "forever stop bot-graze.js",
|
||||
"node": "node bot-graze.js"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"discord.js": "^11.4.2",
|
||||
"dotenv": "^6.1.0",
|
||||
"forever": "^0.15.3",
|
||||
"node-cron": "^1.2.1"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user