diff --git a/examples/jsconfig.json b/examples/jsconfig.json new file mode 100644 index 000000000..ab843b232 --- /dev/null +++ b/examples/jsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "target": "ES6" + } +} \ No newline at end of file diff --git a/examples/adminbot.js b/examples/permissions/adminbot.js similarity index 89% rename from examples/adminbot.js rename to examples/permissions/adminbot.js index 0f21522cf..4aa6dd5af 100644 --- a/examples/adminbot.js +++ b/examples/permissions/adminbot.js @@ -4,10 +4,10 @@ change in the future. */ -var Discord = require("../"); +var Discord = require("../../"); // Get the email and password -var AuthDetails = require("./auth.json"); +var AuthDetails = require("../auth.json"); var bot = new Discord.Client(); diff --git a/examples/permissions.js b/examples/permissions/permissions.js similarity index 50% rename from examples/permissions.js rename to examples/permissions/permissions.js index e336eca2b..518e05ccf 100644 --- a/examples/permissions.js +++ b/examples/permissions/permissions.js @@ -1,41 +1,48 @@ -/* this bot will see if a user can send TTS messages */ - -var Discord = require("../"); - -var AuthDetails = require("./auth.json"); - -var bot = new Discord.Client(); - -bot.on("ready", () => { - console.log("Ready to begin!"); -}); - -bot.on("message", (msg) => { - - 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* send TTS messages."); - - }else{ - - bot.reply(msg, "You *can't* send TTS messages."); - - } - - } - - /* - for a list of more permissions, go to - https://github.com/hydrabolt/discord.js/blob/master/src/EvaluatedPermissions.js - */ - -}) - +/* this bot will see if a user can send TTS messages */ + +var Discord = require("../../"); + +var AuthDetails = require("../auth.json"); + +var bot = new Discord.Client(); + +bot.on("ready", () => { + console.log("Ready to begin!"); +}); + +bot.on("message", (msg) => { + + 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* send TTS messages."); + }else{ + bot.reply(msg, "You *can't* send TTS messages."); + } + + }else if(msg.content === "what are my full permissions?"){ + + var user = msg.sender; + + // 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 + */ + +}) + bot.login(AuthDetails.email, AuthDetails.password); \ No newline at end of file