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

Commit 9c654bc

Browse files
RemcoRemco
authored andcommitted
Tweaks
Closes #87
1 parent a36bd5a commit 9c654bc

File tree

2 files changed

+13
-27
lines changed

2 files changed

+13
-27
lines changed

discord_bot.js

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,6 @@ var commands = {
113113
}
114114
}
115115
},
116-
"setgame": {
117-
name: "setgame",
118-
description: "Sets the playing status to a specified game.",
119-
extendedhelp: "This will change my playing status to a given game ID, you can check for a list of game ID's at the wiki of DougleyBot.",
120-
usage: "<game-id>",
121-
process: function(bot, msg, suffix) {
122-
bot.setPlayingGame(suffix);
123-
Logger.log("debug", "The playing status has been changed to " + suffix + " by " + msg.sender.username);
124-
}
125-
},
126116
"cleverbot": {
127117
name: "cleverbot",
128118
description: "Talk to Cleverbot!",
@@ -287,13 +277,17 @@ var commands = {
287277
},
288278
"purge": {
289279
name: "purge",
290-
usage: "<number-of-messages-to-delete>",
280+
usage: "<number-of-messages-to-delete> [force]",
291281
extendedhelp: "I'll delete a certain ammount of messages.",
292282
process: function(bot, msg, suffix) {
293283
if (!msg.channel.server) {
294284
bot.sendMessage(msg.channel, "You can't do that in a DM, dummy!");
295285
return;
296286
}
287+
if (!suffix){
288+
bot.sendMessage(msg.channel, "Please define an ammount of messages for me to delete!");
289+
return;
290+
}
297291
if (!msg.channel.permissionsOf(msg.sender).hasPermission("manageMessages")) {
298292
bot.sendMessage(msg.channel, "Sorry, your permissions doesn't allow that.");
299293
return;
@@ -302,11 +296,11 @@ var commands = {
302296
bot.sendMessage(msg.channel, "I don't have permission to do that!");
303297
return;
304298
}
305-
if (suffix > 20 && msg.content != "force"){
299+
if (suffix.split(" ")[0] > 20 && msg.content != "force"){
306300
bot.sendMessage(msg.channel, "I can't delete that much messages in safe-mode, add `force` to your message to force me to delete.");
307301
return;
308302
}
309-
if (suffix > 99){
303+
if (suffix.split(" ")[0] > 100){
310304
bot.sendMessage(msg.channel, "The maximum is 100, 20 without `force`.");
311305
return;
312306
}
@@ -328,7 +322,7 @@ var commands = {
328322
delcount++;
329323
if (todo === 0){
330324
bot.sendMessage(msg.channel, "Done! Deleted " + delcount + " messages.");
331-
Logger.info("Ending purge");
325+
Logger.info("Ending purge, deleted " + delcount + " messages.");
332326
return;
333327
}}
334328
}
@@ -510,16 +504,6 @@ var commands = {
510504
}
511505
}
512506
},
513-
"refresh": {
514-
name: "refresh",
515-
description: "Refreshes the game status.",
516-
extendedhelp: "I'll refresh my playing status to a new random game!",
517-
process: function(bot, msg) {
518-
bot.sendMessage(msg.channel, "I'm refreshing my playing status.");
519-
bot.setPlayingGame(Math.floor(Math.random() * (max - min)) + min);
520-
Logger.log("debug", "The playing status has been refreshed");
521-
}
522-
},
523507
"image": {
524508
name: "image",
525509
description: "Gets image matching tags from Google.",
@@ -707,7 +691,7 @@ var commands = {
707691
if (suffix[0] === bot.user.username) {
708692
Logger.log("debug", bot.joinServer(suffix[1], function(error, server) {
709693
Logger.log("debug", "callback: " + arguments);
710-
if (error) {
694+
if (error || !server) {
711695
Logger.warn("Failed to join a server: " + error);
712696
bot.sendMessage(msg.channel, "Something went wrong, try again.");
713697
} else {
@@ -1181,7 +1165,6 @@ bot.on("ready", function() {
11811165
bot.joinServer(ConfigFile.join_servers_on_startup);
11821166
Logger.log("info", "I've joined the servers defined in my config file.");
11831167
Logger.log("info", "Ready to begin! Serving in " + bot.channels.length + " channels");
1184-
bot.setPlayingGame(Math.floor(Math.random() * (max - min)) + min);
11851168
});
11861169

11871170
bot.on("disconnected", function() {

test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,7 @@ function EndTest(){
164164
}
165165

166166
console.log("Beginning bot testing, logging in.");
167-
bot.login(process.env.ds_email, process.env.ds_password).then(init);
167+
bot.login(process.env.ds_email, process.env.ds_password).then(init).catch(err);
168+
function err(error){
169+
console.log("Logging in failed!");
170+
}

0 commit comments

Comments
 (0)