diff --git a/README.md b/README.md index c8c73cc..2fc3875 100644 --- a/README.md +++ b/README.md @@ -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)]() diff --git a/discord_bot.js b/discord_bot.js index d88164b..c134eb2 100644 --- a/discord_bot.js +++ b/discord_bot.js @@ -6,6 +6,8 @@ */ var pmx = require('pmx').init(); +var maintenance; + var version = "1.1.4"; var Discord = require("discord.js"); @@ -141,6 +143,26 @@ var commands = { }); } }, + "maintenance-mode": { + adminOnly: true, + description: "Enables maintenance mode.", + usage: "", + 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) { @@ -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]; diff --git a/package.json b/package.json index 7e50532..83956fa 100644 --- a/package.json +++ b/package.json @@ -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": [], @@ -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": "*",