This is NOT a question about Discord, but about how a feature on Discord was implemented.
Discord has a system in place where a set of numbers added together can represent a set of selected permissions. I spent some time looking around the internet and playing with Discord's link generator to form an understanding of what is happening but I haven't been successful.
In the following image, it can be seen that I have selected a set of permissions for a small bot and in the generated URL a number is provided under the permissions parameter:

What I don't understand is, how are the numbers (for each permission) assigned such that when any combination of numbers is added together there are no conflicting/ambiguous results?
Also, once a number is generated, how are the numbers interpreted and converted back to their original meanings?
CodePudding user response:
Every individual tickbox corresponds to one bit position. The final number is the binary number obtained by writing "1" at every ticked position and "0" at every non-ticked position.
For instance, "Manage channels" is 0b00010000 = 16 and "View audit log" is 0b10000000 = 128, hence if you tick both "Manage channels" and "View audit log" and nothing else, you'll get 0b10010000 = 144.
