y21

Untitled

y21
Jan 22nd, 2021 (edited)
151
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Permission strings in the same order as Discord calculates the bitset
  2. let permissions = [
  3.   'CREATE_INSTANT_INVITE',
  4.   'KICK_MEMBERS',
  5.   'BAN_MEMBERS',
  6.   'ADMINISTRATOR',
  7.   'MANAGE_CHANNELS',
  8.   'MANAGE_GUILD',
  9.   'ADD_REACTIONS',
  10.   'VIEW_AUDIT_LOG',
  11.   'PRIORITY_SPEAKER',
  12.   'STREAM',
  13.   'VIEW_CHANNEL',
  14.   'SEND_MESSAGES',
  15.   'SEND_TTS_MESSAGES',
  16.   'MANAGE_MESSAGES',
  17.   'EMBED_LINKS',
  18.   'ATTACH_FILES',
  19.   'READ_MESSAGE_HISTORY',
  20.   'MENTION_EVERYONE',
  21.   'USE_EXTERNAL_EMOJIS',
  22.   'VIEW_GUILD_ANALYTICS',
  23.   'CONNECT',
  24.   'SPEAK',
  25.   'MUTE_MEMBERS',
  26.   'DEAFEN_MEMBERS',
  27.   'MOVE_MEMBERS',
  28.   'USE_VAD',
  29.   'CHANGE_NICKNAME',
  30.   'CHANGE_NICKNAMES',
  31.   'MANAGE_ROLES',
  32.   'MANAGE_WEBHOOKS',
  33.   'MANAGE_EMOJIS'
  34. ];
  35.  
  36. // Old permission bitset
  37. let old = (1 << 5) | (1 << 6);
  38.  
  39. // New permission bitset
  40. let ne = (1 << 5); // <-- ADD_REACTIONS bit is missing
  41.  
  42. permissions.filter((_, i) => {
  43.     return (old & (1 << i)) && !(ne & (1 << i));
  44. }); // => ['ADD_REACTIONS']
  45.  
RAW Paste Data