Update Examples (closes #380) (#383)

* Update examples

* Forgot to save send-files
This commit is contained in:
Manuel Kraus
2016-05-29 03:55:39 +02:00
committed by abalabahaha
parent b9506d01ab
commit 8d64435def
9 changed files with 114 additions and 176 deletions

View File

@@ -2,8 +2,6 @@
var Discord = require("../../");
Discord.patchStrings();
var AuthDetails = require("../auth.json");
var bot = new Discord.Client();
@@ -13,38 +11,36 @@ bot.on("ready", () => {
});
bot.on("message", (msg) => {
var user = msg.author;
if(msg.content === "can I tts?"){
var user = msg.sender;
// get the evaluated permissions for a user in the channel they asked
var permissions = msg.channel.permissionsOf(user);
if(permissions.sendTTSMessages){
bot.reply(msg, "You " + "can".italic.bold + " send TTS messages.");
}else{
bot.reply(msg, "You " + "can't".italic.bold + " send TTS messages.");
}
}else if(msg.content === "what are my full permissions?"){
var user = msg.sender;
if(permissions.sendTTSMessages)
bot.reply(msg, "You ***can*** send TTS messages.");
else
bot.reply(msg, "You ***can't*** send TTS messages.");
} else if(msg.content === "what are my full permissions?") {
// get the serialised permissions of the user
var permissions = msg.channel.permissionsOf(user).serialise();
// if you want to stringify permissions, they need to be serialised first.
bot.reply(msg, JSON.stringify(permissions, null, 4).replace(/true/g, "**true**"));
}
/*
for a list of more permissions, go to
https://github.com/hydrabolt/discord.js/blob/master/src/EvaluatedPermissions.js
http://discordjs.readthedocs.io/en/indev/docs_permissionconstants.html
*/
})
bot.login(AuthDetails.email, AuthDetails.password);
bot.loginWithToken(AuthDetails.token);