'BanMembers': your editor completes them and refuses a typo. Nothing here sends a request: everything is computed from what the bot knows.
Where permissions come from
To write permissions, pass names to
guild.createRole(), role.edit() (RoleCreateOptions, RoleEditOptions) and channel.setPermissions().
How they are computed
The computation follows the permission rules of Discord, in four steps:- In the server. The owner can do everything. Otherwise a member has what the @everyone role allows, plus what each of their roles allows; a member with
Administratorcan do everything. - In a channel. The overwrites of the channel change that: first the one for @everyone, then the ones for the roles of the member combined, then the one for the member themselves. Each one removes what it denies, then adds what it allows. An administrator is never affected by overwrites.
- What follows. A member who can’t
ViewChannelcan do nothing in it. A member who can’tSendMessagescan’tMentionEveryone,SendTtsMessages,AttachFilesorEmbedLinkseither. - Timed out. A timed out member only keeps
ViewChannelandReadMessageHistory, unless they are an administrator.
member.permissions applies steps 1 and 4; member.permissionsIn(channel) and channel.permissionsFor(member) apply all four. A thread uses the permissions of the channel it is in.
Permissions
A set of permissions that never changes: every operation returns a new set. Discord serializes permissions as text because they don’t fit in a regular number.Properties
constructor
'2048'). Without an argument, the set is empty. A name that is not a permission throws a TypeError:
has()
{ checkAdmin: false } is passed.
any()
missing()
add()
remove()
toArray()
toString()
toJSON()
has(), any() and missing() answer for an administrator as if they had everything. Pass { checkAdmin: false } to has() or any() to check the exact bit.PermissionResolvable
A permission, or several: by name, as bits, or as a set.Permissions, and every option that takes permissions, accepts one. Something else than a name, a bigint, a set or a list of those throws a TypeError:
PermissionName
The name of one permission: a key ofPermissionFlags, as listed below.
Discord documentation
PermissionFlags
The bit of every permission, by name:PermissionFlags.BanMembers is 4n (1n << 2n). It is what PermissionName is made of, and what bits is read against.
| or to compare with a number from elsewhere.
Discord documentation
The hierarchy
Having a permission is not always enough: a member can only kick, ban, rename or give roles to members whose highest role is below their own.member.isHigherThan(other) and role.isHigherThan(other) answer that. The same applies to your bot: its highest role must be above the member it moderates.
Discord documentation