Build

Permissions and role hierarchy

Request the smallest permission set and respect Lyra’s 64-bit role hierarchy.

Permission model

Community permissions are a u64 bit field. Effective access combines @everyone, assigned roles and channel overwrites. Administrator bypasses ordinary permission checks; community owners bypass both permissions and role-position checks. A moderator cannot create, edit or assign a role equal to or above their highest role.

Canonical permission values

BitConstantMeaningDecimal value
0ADMINISTRATORAdministrator1
1VIEW_AUDIT_LOGView audit log2
2MANAGE_GUILDManage community4
3MANAGE_ROLESManage roles8
4MANAGE_CHANNELSManage channels16
5KICK_MEMBERSKick members32
6BAN_MEMBERSBan members64
7CREATE_INVITESCreate invites128
8CHANGE_NICKNAMEChange nickname256
9MANAGE_NICKNAMESManage nicknames512
10MANAGE_EMOJISManage emojis1024
11MANAGE_WEBHOOKSManage webhooks2048
12VIEW_GUILD_INSIGHTSView community insights4096
13MODERATE_MEMBERSModerate members8192
14PROMOTE_TO_UNIVERSEPromote to Universe16384
15VOTE_IN_POLLSVote in polls32768
20VIEW_CHANNELView channels1048576
21SEND_MESSAGESSend messages2097152
22SEND_TTS_MESSAGESSend TTS messages4194304
23MANAGE_MESSAGESManage messages8388608
24EMBED_LINKSEmbed links16777216
25ATTACH_FILESAttach files33554432
26READ_MESSAGE_HISTORYRead message history67108864
27MENTION_EVERYONEMention everyone134217728
28USE_EXTERNAL_EMOJISUse external emojis268435456
29ADD_REACTIONSAdd reactions536870912
30USE_APPLICATION_COMMANDSUse application commands1073741824
31MANAGE_THREADSManage threads2147483648
32CREATE_PUBLIC_THREADSCreate public threads4294967296
33CREATE_PRIVATE_THREADSCreate private threads8589934592
34SEND_MESSAGES_IN_THREADSSend messages in threads17179869184
40CONNECTConnect1099511627776
41SPEAKSpeak2199023255552
42MUTE_MEMBERSMute members4398046511104
43DEAFEN_MEMBERSDeafen members8796093022208
44MOVE_MEMBERSMove members17592186044416
45USE_VOICE_ACTIVITYUse voice activity35184372088832
46PRIORITY_SPEAKERPriority speaker70368744177664
47STREAMStream140737488355328
48START_EMBEDDED_ACTIVITIESStart activities281474976710656
50USE_DRIVEUse Drive1125899906842624
51MANAGE_DRIVEManage Drive2251799813685248

Calculate values safely in JavaScript

JavaScript number bitwise operators truncate to 32 bits. Use BigInt for every permission calculation, then serialize the result as a decimal string in JSON and invitation query parameters.

typescript
const VIEW_CHANNEL = 1n << 20n
const SEND_MESSAGES = 1n << 21n
const READ_MESSAGE_HISTORY = 1n << 26n

const permissions = VIEW_CHANNEL | SEND_MESSAGES | READ_MESSAGE_HISTORY
console.log(permissions.toString()) // 70254592

Least-privilege checklist

  • Do not request Administrator as a convenience
  • Separate read, publish and moderation capabilities
  • Explain sensitive permissions on the consent screen
  • Reinstalling a bot updates its managed role instead of duplicating membership
  • The installer cannot grant permissions they do not possess