Learn to Code via Tutorials on Repl.it!

← Back to all posts
Discord Permissions List (Array form)
almostStatic (106)

Discord Permissions List (In Array Form)

Ever making a command in your discord.js bot and realise that you suddenly need an array containing all of the Discord Permissions?Well, I've got you covered.

[
  'CREATE_INSTANT_INVITE', 'KICK_MEMBERS',
  'BAN_MEMBERS',           'ADMINISTRATOR',
  'MANAGE_CHANNELS',       'MANAGE_GUILD',
  'ADD_REACTIONS',         'VIEW_AUDIT_LOG',
  'PRIORITY_SPEAKER',      'STREAM',
  'VIEW_CHANNEL',          'SEND_MESSAGES',
  'SEND_TTS_MESSAGES',     'MANAGE_MESSAGES',
  'EMBED_LINKS',           'ATTACH_FILES',
  'READ_MESSAGE_HISTORY',  'MENTION_EVERYONE',
  'USE_EXTERNAL_EMOJIS',   'VIEW_GUILD_INSIGHTS',
  'CONNECT',               'SPEAK',
  'MUTE_MEMBERS',          'DEAFEN_MEMBERS',
  'MOVE_MEMBERS',          'USE_VAD',
  'CHANGE_NICKNAME',       'MANAGE_NICKNAMES',
  'MANAGE_ROLES',          'MANAGE_WEBHOOKS',
  'MANAGE_EMOJIS'
]

You can utilise the .map() and .join() methods to map them into a more readable list. In order to replace ALL the _, you will need to utilise a for loop.

I will later create a more in-depth guide to using .map() and .join() later.

Additionally, you can access these permissions directly via Object.keys(require('discord.js').Permissions.FLAGS). You must be on v12.

Comments
hotnewtop
PixelNinja (311)

Ty, I will favorite this post so I can easily get to it.