From b38c63f85531cc873dac18fd21ea2b931a3f33e3 Mon Sep 17 00:00:00 2001 From: hydrabolt Date: Fri, 20 Nov 2015 21:42:03 +0000 Subject: [PATCH] Added permission constants --- docs/docs_permissionconstants.rst | 53 +++++++++++++++++++++++++++++++ docs/index.rst | 9 +++--- docs/vars.rst | 1 + 3 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 docs/docs_permissionconstants.rst diff --git a/docs/docs_permissionconstants.rst b/docs/docs_permissionconstants.rst new file mode 100644 index 000000000..ef10b4b83 --- /dev/null +++ b/docs/docs_permissionconstants.rst @@ -0,0 +1,53 @@ +.. include:: ./vars.rst + +Permission Constants +==================== + +In discord.js, you can handle permissions in two ways. The preferred way is to just use the string name of the permission, alternatively you can use ``Discord.Constants.Permissions["permission name"]``. + +Valid Permission Names +---------------------- + +.. code-block:: js + + { + // general + createInstantInvite, + kickMembers, + banMembers, + manageRoles, + managePermissions, + manageChannels, + manageChannel, + manageServer, + // text + readMessages, + sendMessages, + sendTTSMessages, + manageMessages, + embedLinks, + attachFiles, + readMessageHistory, + mentionEveryone, + // voice + voiceConnect, + voiceSpeak, + voiceMuteMembers, + voiceDeafenMembers, + voiceMoveMembers, + voiceUseVAD + }; + +Preferred Way +------------- + +The preferred way of using permissions in discord.js is to just use the name. E.g: + +``role.hasPermission("voiceUseVAD")`` + +Alternative +----------- + +You can also go the long way round and use the numerical permission like so: + +``role.hasPermission( Discord.Constants.Permissions.voiceUseVAD )`` \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index 94e00758c..d9b7dd199 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -20,7 +20,7 @@ Contents: .. _docs: .. toctree:: - :maxdepth: 2 + :maxdepth: 1 :caption: Channel Documentation docs_channel @@ -30,7 +30,7 @@ Contents: docs_voicechannel .. toctree:: - :maxdepth: 2 + :maxdepth: 1 :caption: Documentation docs_client @@ -40,15 +40,16 @@ Contents: docs_invite .. toctree:: - :maxdepth: 2 + :maxdepth: 1 :caption: Permission Documentation + docs_permissionconstants docs_role docs_permissionoverwrite docs_channelpermissions .. toctree:: - :maxdepth: 2 + :maxdepth: 1 :caption: Util Documentation docs_cache diff --git a/docs/vars.rst b/docs/vars.rst index f0d6fb161..568d46b91 100644 --- a/docs/vars.rst +++ b/docs/vars.rst @@ -13,5 +13,6 @@ .. _Role : ./docs_role.html .. _ChannelPermissions : ./docs_channelpermissions.html .. _PermissionOverwrite : ./docs_permissionoverwrite.html +.. _Permission Constants : ./docs_permissionconstants.html .. _Promises : https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise .. _EventEmitter : https://nodejs.org/api/events.html#events_class_events_eventemitter \ No newline at end of file