Skip to content
This repository has been archived by the owner on Feb 26, 2018. It is now read-only.

Commit

Permalink
Added maintenance-mode
Browse files Browse the repository at this point in the history
Also updated package.json
  • Loading branch information
SteamingMutt authored and SteamingMutt committed Nov 28, 2015
1 parent aa79948 commit 3f24cd6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# DougleyBot
[![Version](https://img.shields.io/badge/Version-1.1.4-green.svg?style=flat-square)](https://github.com/SteamingMutt/DougleyBot/releases)
[![Version](https://img.shields.io/badge/Version-1.1.5-green.svg?style=flat-square)](https://github.com/SteamingMutt/DougleyBot/releases)
[![Status](https://img.shields.io/badge/Status-Ready-green.svg?style=flat-square)]()
[![Node](https://img.shields.io/badge/Node-4.2.1-blue.svg?style=flat-square)](http://nodejs.org)
[![NPM](https://img.shields.io/badge/NPM-2.14.7-blue.svg?style=flat-square)](http://nodejs.org)
[![Node](https://img.shields.io/badge/Node-4.2.2-blue.svg?style=flat-square)](http://nodejs.org)
[![NPM](https://img.shields.io/badge/NPM-3.5.0-blue.svg?style=flat-square)](http://nodejs.org)
[![License](https://img.shields.io/badge/License-GNU-blue.svg?style=flat-square)]()
[![Tested on](https://img.shields.io/badge/Tested%20on-Windows%2010%2FUbuntu%2015.10-lightgrey.svg?style=flat-square)]()

Expand Down
29 changes: 27 additions & 2 deletions discord_bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
var pmx = require('pmx').init();

var maintenance;

var version = "1.1.4";

var Discord = require("discord.js");
Expand Down Expand Up @@ -141,6 +143,26 @@ var commands = {
});
}
},
"maintenance-mode": {
adminOnly: true,
description: "Enables maintenance mode.",
usage: "<time-in-seconds>",
process: function(bot,msg,suffix){
console.log("Maintenance mode activated for " + suffix + " seconds.");
bot.sendMessage(msg.channel, "The bot is now in maintenance mode, commands **will NOT** work!" );
bot.setPlayingGame(525);
bot.setStatusIdle();
maintenance = "true";
setTimeout(continueExecution, Math.round(suffix * 1000));
function continueExecution(){
console.log("Maintenance ended.");
bot.sendMessage(msg.channel, "Maintenance period ended, returning to normal.");
bot.setPlayingGame(308);
bot.setStatusOnline();
maintenance = null;
}
}
},
"ping": {
description: "Responds pong, useful for checking if bot is alive.",
process: function(bot, msg, suffix) {
Expand Down Expand Up @@ -512,8 +534,11 @@ bot.on("message", function (msg) {
// check if message is a command
if(msg.author.id != bot.user.id && (msg.content[0] === '!' || msg.content.indexOf(bot.user.mention()) === 0)){
if(msg.author.equals(bot.user)) { return; }
console.log("treating " + msg.content + " from " + msg.author + " as command");
var cmdTxt = msg.content.split(" ")[0].substring(1);
if (maintenance == "true") {
bot.sendMessage(msg.channel, msg.sender + ", I'm in maintenance mode, I can't take commands right now.");
return;}
console.log("Message recieved, I'm interpeting |" + msg.content + "| from " + msg.author + " as an command");
var cmdTxt = msg.content.split(" ")[0].substring(1);
var suffix = msg.content.substring(cmdTxt.length+2);//add one for the ! and one for the space

var cmd = commands[cmdTxt];
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "DiscordBot",
"version": "0.1.1",
"name": "DougleyBot",
"version": "1.1.5",
"description": "Bot for Discord app",
"readme": "README.md",
"maintainers": [],
Expand All @@ -9,7 +9,7 @@
"type": "git",
"url": "git+https://github.com/SteamingMutt/DougleyBot.git"
},
"license": "GNU",
"license": "GPL-2.0",
"dependencies": {
"cleverbot-node": "0.2.x",
"discord.js": "*",
Expand Down

0 comments on commit 3f24cd6

Please sign in to comment.