-
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Remco
authored and
Remco
committed
Jan 16, 2016
1 parent
54c377b
commit 4e00864
Showing
7 changed files
with
168 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//TODO: Actually make functions here, lmao |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
var Discord = require("discord.js"), | ||
bot = new Discord.Client(), | ||
ConfigFile = require("../config.json"), | ||
Logger = require("./logger.js").Logger, | ||
DebugLogger = require("./logger.js").DebugModeLog, | ||
LogBookID, | ||
ServerID; | ||
|
||
exports.create = function(bot){ | ||
Logger.info("Creating default server..."); | ||
bot.createServer(bot.user.username + " Base Camp", "london", function(error, server){ | ||
if (server){ | ||
Logger.info("Default server sucessfully created."); | ||
var msgArray = []; | ||
msgArray.push("Hello! My name is " + bot.user.username + ", welcome to my base camp!"); | ||
msgArray.push("With this server, you can monitor and contol the bot."); | ||
msgArray.push("`leave` will not function in this server, as I'm the owner of this server, so be assured that I'll always be in at least 1 server."); | ||
msgArray.push("There are some special commands that only work in this server, `adminme` for example if you're my master."); // TODO: Not yet actually, I haven't done that yet. | ||
msgArray.push("Thanks for choosing DougleyBot as your framework, have fun!"); | ||
bot.sendMessage(server.defaultChannel, msgArray); | ||
var step = ConfigFile.default_server.print_to_which_channel.split(" "); | ||
bot.createChannel(server, step.join("-"), function(channel, error){ | ||
if (channel){ | ||
Logger.info("Logbook channel sucessfully created."); | ||
LogBookID = channel.id; | ||
} else if (error){ | ||
Logger.error("Creating the logbook channel failed, got error: " + error); | ||
} | ||
}); | ||
bot.createInvite(server.defaultChannel, function(error, invite){ | ||
if (invite){ | ||
Logger.info("Default server sucessfully created, invite: " + invite); | ||
} else if (error){ | ||
Logger.error("Creating the invite for the default server failed, try manually making an invite via my account, got error: " + error); | ||
} | ||
}); | ||
} else if (error){ | ||
Logger.error("Creating the default server failed, got error: " + error); | ||
} | ||
}); | ||
}; | ||
|
||
exports.logbook = function(entry, user, server){ | ||
Logger.info("About to log something to the logbook: " + entry); | ||
var msgArray = []; | ||
msgArray.push("New logbook entry:"); | ||
msgArray.push("```" + entry + "```"); | ||
msgArray.push("Triggered by " + user + " in server " + server); | ||
bot.sendMessage(LogBookID, msgArray); | ||
}; | ||
|
||
exports.fetch = function(callback){ // TODO: This is the most ridicolous method to fetch this, change to a more sensible method. | ||
callback(ServerID); | ||
}; | ||
|
||
exports.check = function(callback){ | ||
var oldServers = []; | ||
for (var owner in bot.servers) { | ||
oldServers[owner] = bot.servers[owner]; | ||
if (oldServers.indexOf(bot.user) !== -1) { | ||
return callback(true); | ||
} else { | ||
return callback(false); | ||
} | ||
} | ||
}; |