On This Page

Roles and Permissions

23 symbols from @neontechspace/fluxerly

Variables#

Permissions#

Named permission grants for role inputs, channel overwrites and raw permission checks

const Permissions: Readonly<{ … }>

Combine bigint values with |, such as Permissions.ViewChannel | Permissions.SendMessages. Test a grant with (bits & Permissions.SendMessages) === Permissions.SendMessages. Convert bigint to a decimal string before JSON serialization, which cannot serialize bigint directly. These are raw grants, not effective-permission calculations: Hierarchy, channel overwrites and server rules still apply. Unknown unsigned 64-bit bits can be passed explicitly. Fluxer may mask or reject grants

AddReactions#

Start a new emoji reaction on a message, rather than only join an existing reaction

bigint
Administrator#

Grant all permission bits and bypass channel overwrites

Hierarchy and other server checks still apply

bigint
AttachFiles#

Upload files and media with messages

bigint
BanMembers#

Ban accounts from a community and optionally remove their recent messages

bigint
BypassSlowmode#

Send messages without waiting for the channel's per-user slowmode delay

bigint
ChangeNickname#

Change the member's own nickname in the community

bigint
Connect#

Join a voice channel and listen to participants

bigint
CreateExpressions#

Upload custom emoji and stickers and manage the member's own creations

bigint
CreateInstantInvite#

Create invitation links to a community or channel

bigint
CreatePrivateThreads#

Start a private thread in a text channel

bigint
CreatePublicThreads#

Start a public thread or an announcement thread

bigint
DeafenMembers#

Community-deafen other voice participants, preventing them from hearing or speaking

bigint
KickMembers#

Remove members from a community without banning them from joining again

bigint
ManageChannels#

Create, edit or delete community channels and categories

bigint
ManageExpressions#

Edit or delete custom emoji and stickers created by other members

bigint
ManageGuild#

Change community-wide settings, such as its name and icon

bigint
ManageMessages#

Delete other members' messages

Pinning and unpinning use PinMessages separately

bigint
ManageNicknames#

Change other members' community nicknames

bigint
ManageRoles#

Manage roles below the member's highest role and edit channel permission overwrites

bigint
ManageThreads#

Archive, lock, rename and delete threads, see every private thread and act in a locked thread

Guild.mfaLevel describes when an elevated MFA level makes Fluxer reject its use

bigint
ManageWebhooks#

Create, edit or delete webhooks in the applicable community or channel

bigint
MentionEveryone#

Use @everyone and @here, and mention roles even when they are not marked mentionable

bigint
ModerateMembers#

Apply member timeouts that temporarily restrict messaging, reactions and voice participation

bigint
MoveMembers#

Move members between voice channels they can access, or disconnect them from voice

bigint
MuteMembers#

Community-mute other voice participants, preventing them from speaking to everyone

bigint
PinMessages#

Pin or unpin messages, including messages written by other members

bigint
PrioritySpeaker#

Use the priority push-to-talk key binding to make speech stand out over other speakers

bigint
ReadMessageHistory#

Read earlier messages in a channel, subject to community history-cutoff rules

bigint
SendMessages#

Post messages in a channel

bigint
SendMessagesInThreads#

Send messages in threads and add other members to them

In a thread, Fluxer uses this permission in place of SendMessages

bigint
SendTtsMessages#

Send text-to-speech messages that enabled recipients can hear read aloud

bigint
Speak#

Transmit speech in a voice channel

bigint
Stream#

Share a camera or screen in a voice channel

bigint
UpdateRtcRegion#

Change the voice-server region used by a voice channel

bigint
UseExternalEmojis#

Use custom emoji owned by other communities

bigint
UseExternalStickers#

Use custom stickers owned by other communities

bigint
UseVad#

Use voice activity detection to transmit speech without holding a push-to-talk key

bigint
ViewAuditLog#

Read the community's recorded administrative and moderation activity

bigint
ViewChannel#

See a channel, subject to the channel's applicable overwrites

bigint
ViewChannelMembers#

See the member list for the applicable channel

bigint

hierarchy#

Compare roles and members by Fluxer's role hierarchy from snapshots already held, returning plain values

Invalid snapshots throw GuildOperationError with reason input

const hierarchy: HierarchyHelpers
import { hierarchy } from "@neontechspace/fluxerly"
export async function hierarchyExample(client, guildId, actorUserId, targetUserId) {
    const [guild, actor, target, roles] = await Promise.all([
        client.guilds.fetch(guildId),
        client.members.fetch({ guildId, userId: actorUserId }),
        client.members.fetch({ guildId, userId: targetUserId }),
        client.roles.fetchAll(guildId),
    ])
    if (guild.isErr())
        return guild
    if (actor.isErr())
        return actor
    if (target.isErr())
        return target
    if (roles.isErr())
        return roles
    return hierarchy.canManage({ guild: guild.value, actor: actor.value, target: target.value, roles: roles.value })
}
import { hierarchy, type Client } from "@neontechspace/fluxerly"
export async function hierarchyExample(client: Client, guildId: string, actorUserId: string, targetUserId: string) {
    const [guild, actor, target, roles] = await Promise.all([
        client.guilds.fetch(guildId),
        client.members.fetch({ guildId, userId: actorUserId }),
        client.members.fetch({ guildId, userId: targetUserId }),
        client.roles.fetchAll(guildId),
    ])
    if (guild.isErr()) return guild
    if (actor.isErr()) return actor
    if (target.isErr()) return target
    if (roles.isErr()) return roles
    return hierarchy.canManage({ guild: guild.value, actor: actor.value, target: target.value, roles: roles.value })
}

permissionBits#

Build and inspect raw permission flags with bigint values

Use from to combine named permissions, missing to find absent names, and toDecimal to produce a decimal string. Each helper returns a plain value and throws HelperError for unknown names or bits outside the unsigned 64-bit range. These helpers inspect flags only, not whether Fluxer will allow a particular action

const permissionBits: PermissionBitHelpers

Interfaces#

ChannelPermissions#

One entry of the permissions.fetchChannels result: A member's raw permission bits in one community channel

The bits come from the same calculation as permissions.calculate, with the channel's own overwrites. They do not show whether the member can view the channel or whether an action will succeed

interface ChannelPermissions
channel#

The listed community channel, a frozen snapshot with its permission overwrites

GuildChannel
permissions#

The member's permission bits in this channel, an unsigned 64-bit bigint that preserves unknown flags

bigint

GuildRole#

A community role that groups members and supplies permission grants, hierarchy rank and display settings

Every community also has an implicit everyone role whose ID equals the guild ID. This frozen snapshot is not a member's effective permissions and does not update as roles change

interface GuildRole extends RoleReferenceinterface GuildRole
  extends RoleReference
color#

RGB integer, zero means no explicit color

number
hoist#

Whether members with this role are displayed as a separate group in the member list

boolean
hoistPosition optional#

Separate member-list ordering, preserving absent versus null

number | null
icon optional#

Image icon hash, not an image URL

Use assets.roleIcon for its URL. Null means no image icon, and omission means unavailable. A role has at most one of icon and unicodeEmoji

string | null
mentionable#

Whether anyone can mention the role

boolean
name#

Role display name

string
permissions#

Raw grants from Fluxer, including unknown future bits, as an unsigned 64-bit bigint

bigint
position#

Community hierarchy position

Positions can tie, including newly created roles

number
unicodeEmoji optional#

Unicode emoji shown as the role's icon

Null means no emoji, and omission means unavailable

string | null

Inherited from RoleReference: guildId, id

GuildRoleUpdateBulk#

One bulk role update, not individual update events or a complete role list

Unchanged roles may be omitted

interface GuildRoleUpdateBulk
guildId#

Decimal guild ID

string
roles#

Frozen role observations delivered together

readonly GuildRole[]

OverwritePatch#

Changes for permissionBits.patchOverwrite: Which permissions to allow, deny or return to inheritance

Every list is optional, and a permission may appear in at most one of them

interface OverwritePatch
allow optional#

Permissions to allow, which also stops denying them

readonly (
    | "CreateInstantInvite" | "KickMembers" | "BanMembers"
    | "Administrator" | "ManageChannels" | "ManageGuild"
    | "AddReactions" | "ViewAuditLog" | "PrioritySpeaker" | "Stream"
    | "ViewChannel" | "SendMessages" | "SendTtsMessages"
    | "ManageMessages" | "EmbedLinks" | "AttachFiles"
    | "ReadMessageHistory" | "MentionEveryone" | "UseExternalEmojis"
    | "Connect" | "Speak" | "MuteMembers" | "DeafenMembers"
    | "MoveMembers" | "UseVad" | "ChangeNickname"
    | "ManageNicknames" | "ManageRoles" | "ManageWebhooks"
    | "ManageExpressions" | "ManageThreads" | "CreatePublicThreads"
    | "CreatePrivateThreads" | "UseExternalStickers"
    | "SendMessagesInThreads" | "ModerateMembers"
    | "CreateExpressions" | "PinMessages" | "BypassSlowmode"
    | "UpdateRtcRegion" | "ViewChannelMembers")[]readonly (
  | "CreateInstantInvite"
  | "KickMembers" | "BanMembers"
  | "Administrator" | "ManageChannels"
  | "ManageGuild" | "AddReactions"
  | "ViewAuditLog" | "PrioritySpeaker"
  | "Stream" | "ViewChannel"
  | "SendMessages" | "SendTtsMessages"
  | "ManageMessages" | "EmbedLinks"
  | "AttachFiles"
  | "ReadMessageHistory"
  | "MentionEveryone"
  | "UseExternalEmojis" | "Connect"
  | "Speak" | "MuteMembers"
  | "DeafenMembers" | "MoveMembers"
  | "UseVad" | "ChangeNickname"
  | "ManageNicknames" | "ManageRoles"
  | "ManageWebhooks"
  | "ManageExpressions"
  | "ManageThreads"
  | "CreatePublicThreads"
  | "CreatePrivateThreads"
  | "UseExternalStickers"
  | "SendMessagesInThreads"
  | "ModerateMembers"
  | "CreateExpressions"
  | "PinMessages" | "BypassSlowmode"
  | "UpdateRtcRegion"
  | "ViewChannelMembers")[]
deny optional#

Permissions to deny, which also stops allowing them

readonly (
    | "CreateInstantInvite" | "KickMembers" | "BanMembers"
    | "Administrator" | "ManageChannels" | "ManageGuild"
    | "AddReactions" | "ViewAuditLog" | "PrioritySpeaker" | "Stream"
    | "ViewChannel" | "SendMessages" | "SendTtsMessages"
    | "ManageMessages" | "EmbedLinks" | "AttachFiles"
    | "ReadMessageHistory" | "MentionEveryone" | "UseExternalEmojis"
    | "Connect" | "Speak" | "MuteMembers" | "DeafenMembers"
    | "MoveMembers" | "UseVad" | "ChangeNickname"
    | "ManageNicknames" | "ManageRoles" | "ManageWebhooks"
    | "ManageExpressions" | "ManageThreads" | "CreatePublicThreads"
    | "CreatePrivateThreads" | "UseExternalStickers"
    | "SendMessagesInThreads" | "ModerateMembers"
    | "CreateExpressions" | "PinMessages" | "BypassSlowmode"
    | "UpdateRtcRegion" | "ViewChannelMembers")[]readonly (
  | "CreateInstantInvite"
  | "KickMembers" | "BanMembers"
  | "Administrator" | "ManageChannels"
  | "ManageGuild" | "AddReactions"
  | "ViewAuditLog" | "PrioritySpeaker"
  | "Stream" | "ViewChannel"
  | "SendMessages" | "SendTtsMessages"
  | "ManageMessages" | "EmbedLinks"
  | "AttachFiles"
  | "ReadMessageHistory"
  | "MentionEveryone"
  | "UseExternalEmojis" | "Connect"
  | "Speak" | "MuteMembers"
  | "DeafenMembers" | "MoveMembers"
  | "UseVad" | "ChangeNickname"
  | "ManageNicknames" | "ManageRoles"
  | "ManageWebhooks"
  | "ManageExpressions"
  | "ManageThreads"
  | "CreatePublicThreads"
  | "CreatePrivateThreads"
  | "UseExternalStickers"
  | "SendMessagesInThreads"
  | "ModerateMembers"
  | "CreateExpressions"
  | "PinMessages" | "BypassSlowmode"
  | "UpdateRtcRegion"
  | "ViewChannelMembers")[]
inherit optional#

Permissions to neither allow nor deny, so the role's or member's other permissions decide

readonly (
    | "CreateInstantInvite" | "KickMembers" | "BanMembers"
    | "Administrator" | "ManageChannels" | "ManageGuild"
    | "AddReactions" | "ViewAuditLog" | "PrioritySpeaker" | "Stream"
    | "ViewChannel" | "SendMessages" | "SendTtsMessages"
    | "ManageMessages" | "EmbedLinks" | "AttachFiles"
    | "ReadMessageHistory" | "MentionEveryone" | "UseExternalEmojis"
    | "Connect" | "Speak" | "MuteMembers" | "DeafenMembers"
    | "MoveMembers" | "UseVad" | "ChangeNickname"
    | "ManageNicknames" | "ManageRoles" | "ManageWebhooks"
    | "ManageExpressions" | "ManageThreads" | "CreatePublicThreads"
    | "CreatePrivateThreads" | "UseExternalStickers"
    | "SendMessagesInThreads" | "ModerateMembers"
    | "CreateExpressions" | "PinMessages" | "BypassSlowmode"
    | "UpdateRtcRegion" | "ViewChannelMembers")[]readonly (
  | "CreateInstantInvite"
  | "KickMembers" | "BanMembers"
  | "Administrator" | "ManageChannels"
  | "ManageGuild" | "AddReactions"
  | "ViewAuditLog" | "PrioritySpeaker"
  | "Stream" | "ViewChannel"
  | "SendMessages" | "SendTtsMessages"
  | "ManageMessages" | "EmbedLinks"
  | "AttachFiles"
  | "ReadMessageHistory"
  | "MentionEveryone"
  | "UseExternalEmojis" | "Connect"
  | "Speak" | "MuteMembers"
  | "DeafenMembers" | "MoveMembers"
  | "UseVad" | "ChangeNickname"
  | "ManageNicknames" | "ManageRoles"
  | "ManageWebhooks"
  | "ManageExpressions"
  | "ManageThreads"
  | "CreatePublicThreads"
  | "CreatePrivateThreads"
  | "UseExternalStickers"
  | "SendMessagesInThreads"
  | "ModerateMembers"
  | "CreateExpressions"
  | "PinMessages" | "BypassSlowmode"
  | "UpdateRtcRegion"
  | "ViewChannelMembers")[]

PermissionBitInspection#

Known permission names and any unnamed bits found by permissionBits.inspect

This object and its names array are frozen. They do not decide what a user may do

interface PermissionBitInspection
names#

Present known names in Permissions declaration order, not sorted by display label

readonly (
    | "CreateInstantInvite" | "KickMembers" | "BanMembers"
    | "Administrator" | "ManageChannels" | "ManageGuild"
    | "AddReactions" | "ViewAuditLog" | "PrioritySpeaker" | "Stream"
    | "ViewChannel" | "SendMessages" | "SendTtsMessages"
    | "ManageMessages" | "EmbedLinks" | "AttachFiles"
    | "ReadMessageHistory" | "MentionEveryone" | "UseExternalEmojis"
    | "Connect" | "Speak" | "MuteMembers" | "DeafenMembers"
    | "MoveMembers" | "UseVad" | "ChangeNickname"
    | "ManageNicknames" | "ManageRoles" | "ManageWebhooks"
    | "ManageExpressions" | "ManageThreads" | "CreatePublicThreads"
    | "CreatePrivateThreads" | "UseExternalStickers"
    | "SendMessagesInThreads" | "ModerateMembers"
    | "CreateExpressions" | "PinMessages" | "BypassSlowmode"
    | "UpdateRtcRegion" | "ViewChannelMembers")[]readonly (
  | "CreateInstantInvite"
  | "KickMembers" | "BanMembers"
  | "Administrator" | "ManageChannels"
  | "ManageGuild" | "AddReactions"
  | "ViewAuditLog" | "PrioritySpeaker"
  | "Stream" | "ViewChannel"
  | "SendMessages" | "SendTtsMessages"
  | "ManageMessages" | "EmbedLinks"
  | "AttachFiles"
  | "ReadMessageHistory"
  | "MentionEveryone"
  | "UseExternalEmojis" | "Connect"
  | "Speak" | "MuteMembers"
  | "DeafenMembers" | "MoveMembers"
  | "UseVad" | "ChangeNickname"
  | "ManageNicknames" | "ManageRoles"
  | "ManageWebhooks"
  | "ManageExpressions"
  | "ManageThreads"
  | "CreatePublicThreads"
  | "CreatePrivateThreads"
  | "UseExternalStickers"
  | "SendMessagesInThreads"
  | "ModerateMembers"
  | "CreateExpressions"
  | "PinMessages" | "BypassSlowmode"
  | "UpdateRtcRegion"
  | "ViewChannelMembers")[]
unknownBits#

Present bits without a known name, preserved exactly rather than discarded

bigint

PermissionHelpers#

Calculate permission flags from supplied data or fresh reads

A permission value alone does not determine channel visibility, role hierarchy, timeouts or authorization for an action

interface PermissionHelpers

calculate#

Calculate permission flags from supplied guild, member, role and optional channel data

No request or cache read is made, and connection state is irrelevant, including after client shutdown. The bigint result ranges from 0n through 18_446_744_073_709_551_615n and preserves unknown flags. Community owner or base Administrator gets all flags. Otherwise the calculation applies everyone, combined roles, then member overwrites. Only the target channel's stored overwrites are used, not its parent category's. A thread uses the overwrites of the parentChannel supplied with it, then grants SendMessages exactly when SendMessagesInThreads is granted, as Fluxer does. A thread without its parentChannel, or with any other channel as parentChannel, is rejected. Missing or inconsistent input is misuse and throws GuildOperationError for permissions.calculate with reason input in both APIs. A timed-out member keeps its permission bits, but Fluxer blocks sending messages, editing and publishing the member's own messages, reacting, uploading, typing, changing the member's own nickname, writing in threads and joining voice, so check members.timeoutState as well

calculate(input: PermissionInput): bigintcalculate(
  input: PermissionInput
): bigint

Parameters

Returns
bigint

Returns the value synchronously. Unexpected failures throw SdkDefect

fetch#

Fetch guild, member, role and optional channel data, then calculate their permission flags

Use fetchChannels for every channel of a community. No gateway connection is needed, and by default every observation is read fresh without consulting a cache. Set preferCache to take each observation from an enabled cache when it is there and fetch only what is missing. A cached channel without its overwrite list is fetched, and so are all roles when any needed role is not cached. Cached observations reflect the last applied gateway events, which can differ from Fluxer, and they can come from different moments. Cached entries stay while a shard can resume and are cleared when a new session starts, after which they are fetched. Use the default right before an action where a stale grant matters. With caches disabled, preferCache behaves as the default. A thread channel adds a read of its parent channel, and the result follows Fluxer's thread rule as in calculate. Underlying fetches can enter enabled caches, but the calculated result is not cached. The sequential reads are separate observations, so the result does not guarantee a later action will succeed. The default deadline, rest.defaultTimeoutMs (30,000 ms unless configured), covers the whole helper with shared read retries and awaited cancellation cleanup. Only fetches count toward it, so reads served by a cache need no time. Invalid target, deadline or a preferCache that is not a boolean fails with permissions.fetch reason input. Resource errors keep their GuildOperationError or ChannelOperationError. A channel from another community fails instead of mixing guild data, and so does a channel other than a thread that Fluxer sends without its permission overwrite list, with permissions.fetch reason response, outcome unknown, details.read and details.channelId. Client closure fails with ClientClosedError. Its outcome is notDispatched when the client closes before a read is sent or during a cache lookup, including when every observation is cached, rejected while a read waits out a 429 before its retry, and unknown with details.read while a read is in flight

fetch(
    target: PermissionTarget,
    options?: PermissionFetchOptions
): ResultAsync<
    bigint,
    | ClientClosedError | ChannelOperationError | ConfigurationError
    | GuildOperationError | CancelledError
>fetch(
  target: PermissionTarget,
  options?: PermissionFetchOptions
): ResultAsync<
  bigint,
  | ClientClosedError
  | ChannelOperationError
  | ConfigurationError
  | GuildOperationError
  | CancelledError
>

Parameters

options optional
PermissionFetchOptions

fetchChannels#

Fetch one member's permission flags in every channel of a community, such as to see what the bot can do in each channel

Pass the bot's own ID as userId, which client.users.getSelf() returns once the bot has connected. It reads the guild, the member, the role list and the channel list once each, always fresh, then calculates each channel locally the same way as calculate and fetch, so the community owner and an Administrator get every flag. That is four reads for the whole community, where fetch with a channelId takes up to four per channel. Returns a frozen array of frozen { channel, permissions } entries, in the order Fluxer lists the channels. Fluxer lists only the channels the bot can view, so a channel that only the member can view is missing. Threads and forum posts are not listed, so call fetch with a thread's ID for one. The reads happen at different moments, so the result does not guarantee that a later action will succeed. It ignores timeouts and role hierarchy, and a channel's bits do not prove that the member can view it. The reads can fill enabled caches, but the result itself is not cached. Unlike fetch, it has no preferCache, because no cache holds a complete channel list. The default deadline, rest.defaultTimeoutMs (30,000 ms unless configured), covers the whole call, including read retries and awaited cancellation cleanup. An invalid target or deadline fails with permissions.fetchChannels reason input. Errors from the reads keep their GuildOperationError or ChannelOperationError. A listed channel that Fluxer sends without its permission overwrites fails with permissions.fetchChannels reason response, outcome unknown, details.read and details.channelId, as in fetch. Client closure fails with ClientClosedError. Its outcome is notDispatched when the client closes before a read is sent, rejected while a read waits out a 429 before its retry, and unknown with details.read while a read is in flight

fetchChannels(
    target: MemberReference,
    options?: RequestOptions
): ResultAsync<
    readonly ChannelPermissions[],
    | ClientClosedError | ChannelOperationError | ConfigurationError
    | GuildOperationError | CancelledError
>fetchChannels(
  target: MemberReference,
  options?: RequestOptions
): ResultAsync<
  readonly ChannelPermissions[],
  | ClientClosedError
  | ChannelOperationError
  | ConfigurationError
  | GuildOperationError
  | CancelledError
>

Parameters

options optional
RequestOptions
import { permissionBits } from "@neontechspace/fluxerly"

export async function sendableChannels(client, guildId) {
    const botId = client.users.getSelf()?.id
    if (botId === undefined)
        return []
    const result = await client.permissions.fetchChannels({ guildId, userId: botId })
    if (result.isErr())
        throw result.error
    return result.value
        .filter(({ permissions }) => permissionBits.hasAll(permissions, ["ViewChannel", "SendMessages"]))
        .map(({ channel }) => channel.id)
}
import { permissionBits, type Client } from "@neontechspace/fluxerly"

export async function sendableChannels(client: Client, guildId: string) {
    const botId = client.users.getSelf()?.id
    if (botId === undefined) return []
    const result = await client.permissions.fetchChannels({ guildId, userId: botId })
    if (result.isErr()) throw result.error
    return result.value
        .filter(({ permissions }) => permissionBits.hasAll(permissions, ["ViewChannel", "SendMessages"]))
        .map(({ channel }) => channel.id)
}

PermissionInput#

Calculate a member's community or channel permission bits from supplied guild, member, role and channel data

interface PermissionInput

The roles list must include the implicit everyone role whose ID equals guild.id and every role in member.roleIds. Supply channel with permissionOverwrites to include that channel's explicit permission overrides. Omit channel to calculate community-level bits. For a thread, supply the thread as channel and its parent channel, with its overwrites, as parentChannel

The calculation first combines everyone and assigned-role grants. It then applies channel overrides for everyone, the member's roles together, and finally the member. Allows win over denies within each stage. Owners and members with Administrator receive all 64 bits, including unknown bits. A thread has no overwrites of its own, so Fluxer calculates in its parent channel and then grants SendMessages exactly when SendMessagesInThreads is granted there. The calculation does the same

Duplicate, incomplete or cross-community resources fail with GuildOperationError reason input

The calculated bits do not prove that Fluxer will allow an action. The calculation does not check visibility, timeouts, role hierarchy, multi-factor authentication (MFA) or age gates. In a thread it also does not check whether the member can see a private thread, which Fluxer allows only to its members and to members who can manage threads, or whether the thread is archived or locked. The result can become stale immediately after the input was observed

export function permissionsExample(client, input, target) {
    return {
        local: client.permissions.calculate(input),
        remote: client.permissions.fetch(target),
    }
}
import type { Client, PermissionInput, PermissionTarget } from "@neontechspace/fluxerly"

export function permissionsExample(client: Client, input: PermissionInput, target: PermissionTarget) {
    return {
        local: client.permissions.calculate(input),
        remote: client.permissions.fetch(target),
    }
}
channel optional#

Target channel's explicit overwrites, or a thread whose permissions come from parentChannel

Omit for a community-level calculation

GuildChannel
guild#

Community that owns the member, roles, and optional channel

Guild
member#

Membership whose raw permissions are calculated

GuildMember
parentChannel optional#

Parent channel of a thread supplied as channel, with its permission overwrites

Required when channel is a thread, and rejected otherwise. It must be in the same community and have the ID that the thread's parentId names

GuildChannel
roles#

Complete role observations needed to resolve everyone and every member role

readonly GuildRole[]

PermissionOverwrite#

Give or deny channel permissions to one role or member

A permission absent from both allow and deny remains subject to other applicable roles and overwrites. Build these bitfields with Permissions constants and bigint bitwise operators. This is one explicit overwrite, not the member's final permissions. SDK writes accept values through 9_223_372_036_854_775_807n and send ViewChannelMembers replacements to Fluxer. Received values can use the full unsigned 64-bit range

interface PermissionOverwrite
allow#

Permissions explicitly granted here

Writes accept 0n through 9_223_372_036_854_775_807n, and responses can use unsigned 64-bit values. 0n grants nothing explicitly

bigint
deny#

Permissions explicitly denied here

Writes accept 0n through 9_223_372_036_854_775_807n, and responses can use unsigned 64-bit values. 0n denies nothing explicitly

bigint
id#

Decimal role or member ID

string
type#

Whether id identifies a role or a community member

"role" | "member"

PermissionTarget#

Choose whose permission bits permissions.fetch should calculate, by default from fresh REST reads

interface PermissionTarget extends MemberReferenceinterface PermissionTarget
  extends MemberReference

Supply channelId to include a separate target-channel read, or omit it for community-level bits. The client reads guild, member, roles and optional channel in that order under one total deadline, without consulting caches unless preferCache is set. When the channel is a thread, the client also reads its parent channel under the same deadline and calculates as Fluxer does for the thread. Resources can change between reads. The result is not one simultaneous snapshot and does not guarantee that Fluxer will allow an action

channelId optional#

Decimal community-channel ID for a channel-scoped calculation

string

Inherited from MemberReference: guildId, userId

RoleCreate#

Create a named community role with an optional color and permission grants

New roles have no grants by default in this SDK. Use roles.edit afterward for hoist and mentionable settings. Role creation does not assign the role to a member, and Fluxer chooses its initial hierarchy position

interface RoleCreate
color optional#

RGB integer 0–16,777,215, default 0

number
icon optional#

Image data URI for the role's icon, or null for none

Fluxer accepts a still image of at most 256 KiB and from 32 through 1024 pixels on each side. It cannot be combined with an emoji or iconSourceRoleId

string | null
iconSourceRoleId optional#

ID of a role in this community whose icon the new role copies

An image is stored again, so the copy outlives the source

string
name#

Role name, 1–100 UTF-16 code units after U+000C and U+202E removal and surrounding-whitespace trimming

The original string is sent unchanged

string
permissions optional#

Bigint from 0n through 9_223_372_036_854_775_807n, default 0n: Unlike raw Fluxer, never inherit everyone's grants implicitly

Explicit ViewChannelMembers replacements are advertised to Fluxer by the SDK

bigint
unicodeEmoji optional#

A single Unicode emoji to show as the role's icon, or null for none

Fluxer refuses text and more than one emoji

string | null

RoleEdit#

Change the name, grants or display settings of an existing role

Omitted fields stay unchanged and at least one defined field is required. The permissions field replaces grants instead of adding to them. The implicit everyone role accepts only color and permissions. Use roles.reorder for hierarchy rank

interface RoleEdit
color optional#

RGB integer 0–16,777,215

number
hoist optional#

Display members separately

boolean
hoistPosition optional#

Signed 32-bit member-list position

Null clears it

number | null
icon optional#

Image data URI for the role's icon, under the same limits as RoleCreate.icon, or null to remove the image

Setting an image replaces an emoji icon, and both together fail

string | null
mentionable optional#

Allow anyone to mention this role

boolean
name optional#

Role name, 1–100 UTF-16 code units after U+000C and U+202E removal and surrounding-whitespace trimming

The original string is sent unchanged

string
permissions optional#

Replace raw grants with a bigint from 0n through 9_223_372_036_854_775_807n, not an incremental grant

Explicit ViewChannelMembers replacements are advertised to Fluxer by the SDK

bigint
unicodeEmoji optional#

A single Unicode emoji to show as the role's icon, or null to remove it

Setting an emoji replaces an image icon

string | null

RoleHierarchyInput#

Check whether one community member outranks another using guild, member and role snapshots already held by the caller

Supply the actor who would perform the action and the target they would act on. The hierarchy.canManage function checks rank only, without fetching resources or authorizing moderation

interface RoleHierarchyInput
actor#

Member whose hierarchy rank is being evaluated

GuildMember
guild#

Community that owns the actor, target, and supplied role observations

Guild
roles#

Role observations for every explicit role assigned to actor or target

readonly GuildRole[]
target#

Member the actor would need to outrank

GuildMember

RoleHoistPosition#

One display-order assignment, independent of permission hierarchy and the role's hoist flag

interface RoleHoistPosition
hoistPosition#

Signed 32-bit display ordering value, not the permission-hierarchy position

number
id#

Decimal role ID, excluding everyone

string

RoleManagementInput#

Check whether a community member's rank allows managing one role using guild, member and role snapshots already held by the caller

Supply the actor who would manage the role and the role they would act on. The hierarchy.canManageRole function checks rank only, without fetching resources or authorizing role changes

interface RoleManagementInput
actor#

Member whose hierarchy rank is being evaluated

GuildMember
guild#

Community that owns the actor, role, and supplied role observations

Guild
role#

Role the actor would need to outrank

It need not appear in roles

GuildRole
roles#

Role observations for every explicit role assigned to the actor

readonly GuildRole[]

RolePosition#

One requested hierarchy position, not an absolute final-position guarantee

interface RolePosition
id#

Decimal role ID, excluding the implicit everyone role

string
position#

Nonnegative safe integer ordering value

Fluxer normalizes positions and applies manageable-role constraints

number

RoleReference#

Address one role inside its owning community for role reads and changes, without fetching it or retaining a client

interface RoleReference
guildId#

Decimal guild ID

string
id#

Decimal role ID

string

Roles#

Create, edit, order and delete community roles, or read their current or cached data

Shared Guilds request limits, deadlines and read retries apply. Fluxer enforces permissions and hierarchy. No local permission prediction is performed

interface Roles

Writes retry only confirmed HTTP 429 rejection. Abort waits for request cleanup but cannot undo a dispatched write

Expected failures return GuildOperationError or ClientClosedError. Unexpected failures reject with SdkDefect. Inputs are copied when called. Results are snapshots, not gateway acknowledgement. Role permissions use bigint, which requires explicit conversion before JSON serialization. Every remote role mutation accepts AuditedRequestOptions. The fetchAll method rejects auditReason

create#

Create a role with a name, optional color and permission flags

The permissions input defaults to 0n, rather than copying the everyone role's grants. Supplied permissions must be from 0n through 9_223_372_036_854_775_807n. Explicit permissions use Fluxer's feature opt-in for ViewChannelMembers. The result reports the actual server grants, which can differ from the request. Use a separate edit to change hoist or mentionable settings. The application manages the created role afterward. After an unknown outcome, use fetchAll before deciding whether to create again

create(
    guildId: string,
    input: RoleCreate,
    options?: AuditedRequestOptions
): ResultAsync<
    GuildRole,
    ConfigurationError | GuildOperationFailure | CancelledError
>create(
  guildId: string,
  input: RoleCreate,
  options?: AuditedRequestOptions
): ResultAsync<
  GuildRole,
  | ConfigurationError
  | GuildOperationFailure
  | CancelledError
>

Parameters

guildId
string
options optional
AuditedRequestOptions
import { Permissions } from "@neontechspace/fluxerly"
export async function createRoleExample(client, guildId) {
    const result = await client.roles.create(guildId, {
        name: "Readers",
        permissions: Permissions.ViewChannel | Permissions.ReadMessageHistory,
    })
    if (result.isErr())
        throw result.error
    return result.value
}
import { Permissions, type Client } from "@neontechspace/fluxerly"
export async function createRoleExample(client: Client, guildId: string) {
    const result = await client.roles.create(guildId, {
        name: "Readers",
        permissions: Permissions.ViewChannel | Permissions.ReadMessageHistory,
    })
    if (result.isErr()) throw result.error
    return result.value
}

delete#

Delete a role and remove its member assignments in Fluxer

The everyone role cannot be deleted. Fluxer removes the role from each member in separate writes before it deletes the role, and does not roll them back. A failure can leave the role in place after some members already lost it, so fetch the role and the affected members again before retrying. HTTP 204 succeeds with no value, without proving member-event delivery. Snapshots already returned to the caller remain unchanged

delete(
    role: RoleReference,
    options?: AuditedRequestOptions
): ResultAsync<
    void,
    ConfigurationError | GuildOperationFailure | CancelledError
>delete(
  role: RoleReference,
  options?: AuditedRequestOptions
): ResultAsync<
  void,
  | ConfigurationError
  | GuildOperationFailure
  | CancelledError
>

Parameters

options optional
AuditedRequestOptions

edit#

Change only supplied role fields and return the server's snapshot

Empty inputs and unknown fields fail locally. The permissions input replaces all raw grants rather than adding flags, and can set or clear ViewChannelMembers. The replacement must be from 0n through 9_223_372_036_854_775_807n, and larger received masks cannot be written unchanged. The everyone role accepts only color and permissions. Other supplied fields fail, even in a mixed input

edit(
    role: RoleReference,
    input: RoleEdit,
    options?: AuditedRequestOptions
): ResultAsync<
    GuildRole,
    ConfigurationError | GuildOperationFailure | CancelledError
>edit(
  role: RoleReference,
  input: RoleEdit,
  options?: AuditedRequestOptions
): ResultAsync<
  GuildRole,
  | ConfigurationError
  | GuildOperationFailure
  | CancelledError
>

Parameters

input
RoleEdit
options optional
AuditedRequestOptions

fetchAll#

Fetch the community's current role list, including everyone, in server order

This always reads remotely, without pagination or background refresh

fetchAll(guildId: string, options?: RequestOptions): ResultAsync<
    readonly GuildRole[],
    ConfigurationError | GuildOperationFailure | CancelledError
>fetchAll(
  guildId: string,
  options?: RequestOptions
): ResultAsync<
  readonly GuildRole[],
  | ConfigurationError
  | GuildOperationFailure
  | CancelledError
>

Parameters

guildId
string
options optional
RequestOptions

get#

Look up a role by decimal guildId and id in the enabled cache, including the everyone role

No request is made. The cache misses, stale-snapshot warnings, misuse and recency rules of guilds.get apply

get(role: RoleReference): GuildRole | undefinedget(
  role: RoleReference
): GuildRole | undefined

Parameters

Returns
GuildRole | undefined

Returns the value synchronously. Unexpected failures throw SdkDefect

getAll#

Look up every role of a community by decimal guildId in the enabled cache, including the everyone role

No request is made. The frozen list is ordered as roles.fetchAll orders it, highest in the hierarchy first: Larger positions first, and the smaller numeric ID first between equal positions. The result is undefined unless the cache holds the complete list. A guildCreate event makes the list complete, as does a full role read, such as roles.fetchAll, that finishes while the community's shard is connected, when no role event, role write or lost connection overlapped it. Only role events keep the list current, so a read while that shard is not connected, such as before connect, leaves it unknown. Later role create and update events keep it complete. Removing any of the community's roles makes it unknown again, whether by a role deletion event, expiry, capacity eviction, cache.delete or cache.clear, as does a role the cache does not keep because of its limits or maxAgeMs. So does every role write by the bot that succeeds or has an unknown outcome, including create, edit and reorder. A shard's new session, including its first, makes it unknown until the next guildCreate, while a resumed session keeps it. The roles limit, 1,000 entries unless configured, counts roles of every community together, so a bot in many communities needs a larger limit to keep complete lists. An invalid ID is misuse: The default API throws GuildOperationError with reason input and the native API dies with it. A closing or closed client has no cache, so the result is undefined

getAll(guildId: string): readonly GuildRole[] | undefinedgetAll(
  guildId: string
): readonly GuildRole[] | undefined

Parameters

guildId
string
Returns
readonly GuildRole[] | undefined

Returns the value synchronously. Unexpected failures throw SdkDefect

export async function roleNamesExample(client, guildId) {
    const cached = client.roles.getAll(guildId)
    if (cached)
        return cached.map((role) => role.name)
    const fetched = await client.roles.fetchAll(guildId)
    if (fetched.isErr())
        throw fetched.error
    return fetched.value.map((role) => role.name)
}
import type { Client } from "@neontechspace/fluxerly"
export async function roleNamesExample(client: Client, guildId: string) {
    const cached = client.roles.getAll(guildId)
    if (cached) return cached.map((role) => role.name)
    const fetched = await client.roles.fetchAll(guildId)
    if (fetched.isErr()) throw fetched.error
    return fetched.value.map((role) => role.name)
}

reorder#

Change role hierarchy positions using distinct role IDs and nonnegative safe-integer positions

The everyone role cannot move. HTTP 204 succeeds with no value and no new role list. Fluxer normalizes manageable positions, so use fetchAll if final order matters. This is not a transaction. A failure can leave partial changes, requiring a fresh read before recovery

reorder(
    guildId: string,
    positions: readonly RolePosition[],
    options?: AuditedRequestOptions
): ResultAsync<
    void,
    ConfigurationError | GuildOperationFailure | CancelledError
>reorder(
  guildId: string,
  positions:
    readonly RolePosition[],
  options?: AuditedRequestOptions
): ResultAsync<
  void,
  | ConfigurationError
  | GuildOperationFailure
  | CancelledError
>

Parameters

guildId
string
positions
readonly RolePosition[]
options optional
AuditedRequestOptions

resetHoistPositions#

Clear display-position assignments across the community, including roles above the bot

Fluxer requires ManageRoles. Permission hierarchy and hoist flags remain unchanged. HTTP 204 succeeds with no value, not a role list. Changes are not transactional and a failure can be partial. Successful writes and writes with unknown outcomes invalidate cached guild roles. Refetch to resolve an unknown outcome

resetHoistPositions(
    guildId: string,
    options?: AuditedRequestOptions
): ResultAsync<
    void,
    ConfigurationError | GuildOperationFailure | CancelledError
>resetHoistPositions(
  guildId: string,
  options?: AuditedRequestOptions
): ResultAsync<
  void,
  | ConfigurationError
  | GuildOperationFailure
  | CancelledError
>

Parameters

guildId
string
options optional
AuditedRequestOptions

setHoistPositions#

Set roles' display positions without changing their permission hierarchy or enabling hoist

Pass a nonempty list of distinct role IDs with integer hoistPosition values from -2,147,483,648 through 2,147,483,647. The everyone role is excluded. Fluxer checks ManageRoles and hierarchy. HTTP 204 succeeds with no value, not a role list. Successful writes and writes with unknown outcomes invalidate cached guild roles and conflicting pending reads. Failure or cancellation can leave partial changes. Refetch before deciding to replay

setHoistPositions(
    guildId: string,
    positions: readonly RoleHoistPosition[],
    options?: AuditedRequestOptions
): ResultAsync<
    void,
    ConfigurationError | GuildOperationFailure | CancelledError
>setHoistPositions(
  guildId: string,
  positions:
    readonly RoleHoistPosition[],
  options?: AuditedRequestOptions
): ResultAsync<
  void,
  | ConfigurationError
  | GuildOperationFailure
  | CancelledError
>

Parameters

guildId
string
positions
readonly RoleHoistPosition[]
options optional
AuditedRequestOptions
import {} from "@neontechspace/fluxerly"
export function orderRoleDisplay(client, guildId, roleId) {
    return client.roles.setHoistPositions(guildId, [{ id: roleId, hoistPosition: 0 }])
}
import { type Client } from "@neontechspace/fluxerly"
export function orderRoleDisplay(client: Client, guildId: string, roleId: string) {
    return client.roles.setHoistPositions(guildId, [{ id: roleId, hoistPosition: 0 }])
}

Type Aliases#

HierarchyHelpers#

Compare roles and members by Fluxer's role hierarchy using snapshots the caller already holds

Each method returns a plain value without fetching, retaining input or authorizing an action

type HierarchyHelpers = Readonly<{ … }>type HierarchyHelpers =
    Readonly<{ … }>

canManage#

Check the rank requirement for one member to manage another from supplied snapshots

The community owner and a member targeting itself pass. A non-owner cannot manage the owner. For other targets, the actor's highest explicit role must outrank the target's highest explicit role. An actor with no explicit roles fails. An actor with an explicit role outranks a target with none. The roles list must include one same-community observation for every actor and target role ID. The output of roles.fetchAll may include the implicit everyone role, which is ignored for rank comparison. Members must not list everyone as an explicit role. Malformed, incomplete, duplicate, cross-community or inconsistent snapshots throw GuildOperationError hierarchy.canManage/input without retaining the input. A true result confirms only the rank requirement and does not authorize an action. It does not check permissions, multi-factor authentication (MFA), endpoint-specific requirements, current provider membership or concurrent remote changes. To fetch fresh data and check in one call, use members.fetchCanManage

canManage(input: RoleHierarchyInput): booleancanManage(
  input: RoleHierarchyInput
): boolean

Parameters

Returns
boolean

canManageRole#

Check the rank requirement for one member to manage one role, such as to assign or edit it, from supplied snapshots

The community owner passes. Any other actor passes only when the actor's highest explicit role outranks the role, with equal positions ordered by numeric ID and the smaller ID higher. An actor with no explicit roles fails, and so does an actor whose highest role is the role itself. Administrator does not bypass rank in Fluxer. The roles list must include one same-community observation for every actor role ID, and the role need not be in it. Members must not list everyone as an explicit role. Malformed, incomplete, duplicate or cross-community snapshots throw GuildOperationError hierarchy.canManageRole/input without retaining the input. A true result confirms only the rank requirement and does not authorize an action. Fluxer also requires the ManageRoles permission, which permissionBits.has(permissions.calculate(...), "ManageRoles") checks. Neither check covers multi-factor authentication (MFA), endpoint-specific requirements or concurrent remote changes

canManageRole(input: RoleManagementInput): booleancanManageRole(
  input: RoleManagementInput
): boolean

Parameters

Returns
boolean

compare#

Find which of two roles ranks higher, for example when presenting or checking role order locally

Returns 1 when left is higher, -1 when right is higher, and 0 for the same role. A larger position is higher. Tied positions use the smaller numeric role ID as higher. Malformed or cross-community snapshots throw GuildOperationError hierarchy.compare/input without retaining the input. This reports only which role ranks higher in the supplied data. It does not evaluate permissions, multi-factor authentication (MFA), membership visibility or whether a provider endpoint accepts an action

compare(left: GuildRole, right: GuildRole): -1 | 0 | 1compare(
  left: GuildRole,
  right: GuildRole
): -1 | 0 | 1

Parameters

right
GuildRole
Returns
-1 | 0 | 1

highestRole#

Find the role that gives a member the highest rank, from supplied snapshots

The implicit everyone role is ignored, so a member with no explicit roles gives undefined. Equal positions are ordered by numeric ID, with the smaller ID higher. The roles list must include one same-community observation for every role ID of the member and may include the everyone role, as the output of roles.fetchAll does. The member must not list everyone as an explicit role. Malformed, incomplete, duplicate or cross-community snapshots throw GuildOperationError hierarchy.highestRole/input without retaining the input. This reports rank only, not the member's permissions

highestRole(
    member: GuildMember,
    roles: readonly GuildRole[]
): GuildRole | undefinedhighestRole(
  member: GuildMember,
  roles: readonly GuildRole[]
): GuildRole | undefined

Parameters

roles
readonly GuildRole[]
Returns
GuildRole | undefined

isAbove#

Check whether a supplied role outranks another role, without fetching either one

Equal positions are ordered by numeric ID, with the smaller ID higher. Comparing a role with itself returns false. Malformed or cross-community snapshots throw GuildOperationError hierarchy.isAbove/input without retaining the input. This compares the supplied roles only. It does not check permissions or whether Fluxer will allow an action

isAbove(left: GuildRole, right: GuildRole): booleanisAbove(
  left: GuildRole,
  right: GuildRole
): boolean

Parameters

right
GuildRole
Returns
boolean

PermissionBitHelpers#

Methods of the permissionBits helper, which builds and inspects raw bigint permission flags

Each method returns a plain value and throws HelperError for invalid input

type PermissionBitHelpers = Readonly<{ … }>type PermissionBitHelpers =
    Readonly<{ … }>

from#

Combine names such as ["ManageMessages", "ManageRoles"] into one bigint permission set for role or overwrite inputs

An empty array gives 0n, and duplicates have no extra effect. Administrator remains one flag rather than expanding to all permissions. Throws HelperError for an unknown name

from(
    names: readonly (
        | "CreateInstantInvite" | "KickMembers" | "BanMembers"
        | "Administrator" | "ManageChannels" | "ManageGuild"
        | "AddReactions" | "ViewAuditLog" | "PrioritySpeaker"
        | "Stream" | "ViewChannel" | "SendMessages"
        | "SendTtsMessages" | "ManageMessages" | "EmbedLinks"
        | "AttachFiles" | "ReadMessageHistory" | "MentionEveryone"
        | "UseExternalEmojis" | "Connect" | "Speak" | "MuteMembers"
        | "DeafenMembers" | "MoveMembers" | "UseVad"
        | "ChangeNickname" | "ManageNicknames" | "ManageRoles"
        | "ManageWebhooks" | "ManageExpressions" | "ManageThreads"
        | "CreatePublicThreads" | "CreatePrivateThreads"
        | "UseExternalStickers" | "SendMessagesInThreads"
        | "ModerateMembers" | "CreateExpressions" | "PinMessages"
        | "BypassSlowmode" | "UpdateRtcRegion"
        | "ViewChannelMembers")[]
): bigintfrom(
  names: readonly (
    | "CreateInstantInvite"
    | "KickMembers" | "BanMembers"
    | "Administrator"
    | "ManageChannels"
    | "ManageGuild"
    | "AddReactions"
    | "ViewAuditLog"
    | "PrioritySpeaker" | "Stream"
    | "ViewChannel"
    | "SendMessages"
    | "SendTtsMessages"
    | "ManageMessages"
    | "EmbedLinks" | "AttachFiles"
    | "ReadMessageHistory"
    | "MentionEveryone"
    | "UseExternalEmojis"
    | "Connect" | "Speak"
    | "MuteMembers"
    | "DeafenMembers"
    | "MoveMembers" | "UseVad"
    | "ChangeNickname"
    | "ManageNicknames"
    | "ManageRoles"
    | "ManageWebhooks"
    | "ManageExpressions"
    | "ManageThreads"
    | "CreatePublicThreads"
    | "CreatePrivateThreads"
    | "UseExternalStickers"
    | "SendMessagesInThreads"
    | "ModerateMembers"
    | "CreateExpressions"
    | "PinMessages"
    | "BypassSlowmode"
    | "UpdateRtcRegion"
    | "ViewChannelMembers")[]
): bigint

Parameters

names
readonly (
    | "CreateInstantInvite" | "KickMembers" | "BanMembers"
    | "Administrator" | "ManageChannels" | "ManageGuild"
    | "AddReactions" | "ViewAuditLog" | "PrioritySpeaker" | "Stream"
    | "ViewChannel" | "SendMessages" | "SendTtsMessages"
    | "ManageMessages" | "EmbedLinks" | "AttachFiles"
    | "ReadMessageHistory" | "MentionEveryone" | "UseExternalEmojis"
    | "Connect" | "Speak" | "MuteMembers" | "DeafenMembers"
    | "MoveMembers" | "UseVad" | "ChangeNickname"
    | "ManageNicknames" | "ManageRoles" | "ManageWebhooks"
    | "ManageExpressions" | "ManageThreads" | "CreatePublicThreads"
    | "CreatePrivateThreads" | "UseExternalStickers"
    | "SendMessagesInThreads" | "ModerateMembers"
    | "CreateExpressions" | "PinMessages" | "BypassSlowmode"
    | "UpdateRtcRegion" | "ViewChannelMembers")[]readonly (
  | "CreateInstantInvite"
  | "KickMembers" | "BanMembers"
  | "Administrator" | "ManageChannels"
  | "ManageGuild" | "AddReactions"
  | "ViewAuditLog" | "PrioritySpeaker"
  | "Stream" | "ViewChannel"
  | "SendMessages" | "SendTtsMessages"
  | "ManageMessages" | "EmbedLinks"
  | "AttachFiles"
  | "ReadMessageHistory"
  | "MentionEveryone"
  | "UseExternalEmojis" | "Connect"
  | "Speak" | "MuteMembers"
  | "DeafenMembers" | "MoveMembers"
  | "UseVad" | "ChangeNickname"
  | "ManageNicknames" | "ManageRoles"
  | "ManageWebhooks"
  | "ManageExpressions"
  | "ManageThreads"
  | "CreatePublicThreads"
  | "CreatePrivateThreads"
  | "UseExternalStickers"
  | "SendMessagesInThreads"
  | "ModerateMembers"
  | "CreateExpressions"
  | "PinMessages" | "BypassSlowmode"
  | "UpdateRtcRegion"
  | "ViewChannelMembers")[]
Returns
bigint

has#

Return whether bits contains one named permission

Throws HelperError for bits outside the unsigned 64-bit bigint range or an unknown permission name. This does not calculate inherited permissions or authorize an action

has(
    bits: bigint,
    permission:
        | "CreateInstantInvite" | "KickMembers" | "BanMembers"
        | "Administrator" | "ManageChannels" | "ManageGuild"
        | "AddReactions" | "ViewAuditLog" | "PrioritySpeaker"
        | "Stream" | "ViewChannel" | "SendMessages"
        | "SendTtsMessages" | "ManageMessages" | "EmbedLinks"
        | "AttachFiles" | "ReadMessageHistory" | "MentionEveryone"
        | "UseExternalEmojis" | "Connect" | "Speak" | "MuteMembers"
        | "DeafenMembers" | "MoveMembers" | "UseVad"
        | "ChangeNickname" | "ManageNicknames" | "ManageRoles"
        | "ManageWebhooks" | "ManageExpressions" | "ManageThreads"
        | "CreatePublicThreads" | "CreatePrivateThreads"
        | "UseExternalStickers" | "SendMessagesInThreads"
        | "ModerateMembers" | "CreateExpressions" | "PinMessages"
        | "BypassSlowmode" | "UpdateRtcRegion"
        | "ViewChannelMembers"
): booleanhas(
  bits: bigint,
  permission:
    | "CreateInstantInvite"
    | "KickMembers" | "BanMembers"
    | "Administrator"
    | "ManageChannels"
    | "ManageGuild"
    | "AddReactions"
    | "ViewAuditLog"
    | "PrioritySpeaker" | "Stream"
    | "ViewChannel"
    | "SendMessages"
    | "SendTtsMessages"
    | "ManageMessages"
    | "EmbedLinks" | "AttachFiles"
    | "ReadMessageHistory"
    | "MentionEveryone"
    | "UseExternalEmojis"
    | "Connect" | "Speak"
    | "MuteMembers"
    | "DeafenMembers"
    | "MoveMembers" | "UseVad"
    | "ChangeNickname"
    | "ManageNicknames"
    | "ManageRoles"
    | "ManageWebhooks"
    | "ManageExpressions"
    | "ManageThreads"
    | "CreatePublicThreads"
    | "CreatePrivateThreads"
    | "UseExternalStickers"
    | "SendMessagesInThreads"
    | "ModerateMembers"
    | "CreateExpressions"
    | "PinMessages"
    | "BypassSlowmode"
    | "UpdateRtcRegion"
    | "ViewChannelMembers"
): boolean

Parameters

bits
bigint
permission
| "CreateInstantInvite" | "KickMembers" | "BanMembers"
| "Administrator" | "ManageChannels" | "ManageGuild"
| "AddReactions" | "ViewAuditLog" | "PrioritySpeaker" | "Stream"
| "ViewChannel" | "SendMessages" | "SendTtsMessages"
| "ManageMessages" | "EmbedLinks" | "AttachFiles"
| "ReadMessageHistory" | "MentionEveryone" | "UseExternalEmojis"
| "Connect" | "Speak" | "MuteMembers" | "DeafenMembers"
| "MoveMembers" | "UseVad" | "ChangeNickname" | "ManageNicknames"
| "ManageRoles" | "ManageWebhooks" | "ManageExpressions"
| "ManageThreads" | "CreatePublicThreads" | "CreatePrivateThreads"
| "UseExternalStickers" | "SendMessagesInThreads"
| "ModerateMembers" | "CreateExpressions" | "PinMessages"
| "BypassSlowmode" | "UpdateRtcRegion" | "ViewChannelMembers"| "CreateInstantInvite"
| "KickMembers" | "BanMembers"
| "Administrator" | "ManageChannels"
| "ManageGuild" | "AddReactions"
| "ViewAuditLog" | "PrioritySpeaker"
| "Stream" | "ViewChannel"
| "SendMessages" | "SendTtsMessages"
| "ManageMessages" | "EmbedLinks"
| "AttachFiles" | "ReadMessageHistory"
| "MentionEveryone"
| "UseExternalEmojis" | "Connect"
| "Speak" | "MuteMembers"
| "DeafenMembers" | "MoveMembers"
| "UseVad" | "ChangeNickname"
| "ManageNicknames" | "ManageRoles"
| "ManageWebhooks"
| "ManageExpressions"
| "ManageThreads"
| "CreatePublicThreads"
| "CreatePrivateThreads"
| "UseExternalStickers"
| "SendMessagesInThreads"
| "ModerateMembers"
| "CreateExpressions" | "PinMessages"
| "BypassSlowmode" | "UpdateRtcRegion"
| "ViewChannelMembers"
Returns
boolean

hasAll#

Return true if bits contains every requested permission, including true for an empty names array

Every name is validated even if a permission is missing, and unknown bits are unchanged. Throws HelperError for invalid bits or unknown names

hasAll(
    bits: bigint,
    names: readonly (
        | "CreateInstantInvite" | "KickMembers" | "BanMembers"
        | "Administrator" | "ManageChannels" | "ManageGuild"
        | "AddReactions" | "ViewAuditLog" | "PrioritySpeaker"
        | "Stream" | "ViewChannel" | "SendMessages"
        | "SendTtsMessages" | "ManageMessages" | "EmbedLinks"
        | "AttachFiles" | "ReadMessageHistory" | "MentionEveryone"
        | "UseExternalEmojis" | "Connect" | "Speak" | "MuteMembers"
        | "DeafenMembers" | "MoveMembers" | "UseVad"
        | "ChangeNickname" | "ManageNicknames" | "ManageRoles"
        | "ManageWebhooks" | "ManageExpressions" | "ManageThreads"
        | "CreatePublicThreads" | "CreatePrivateThreads"
        | "UseExternalStickers" | "SendMessagesInThreads"
        | "ModerateMembers" | "CreateExpressions" | "PinMessages"
        | "BypassSlowmode" | "UpdateRtcRegion"
        | "ViewChannelMembers")[]
): booleanhasAll(
  bits: bigint,
  names: readonly (
    | "CreateInstantInvite"
    | "KickMembers" | "BanMembers"
    | "Administrator"
    | "ManageChannels"
    | "ManageGuild"
    | "AddReactions"
    | "ViewAuditLog"
    | "PrioritySpeaker" | "Stream"
    | "ViewChannel"
    | "SendMessages"
    | "SendTtsMessages"
    | "ManageMessages"
    | "EmbedLinks" | "AttachFiles"
    | "ReadMessageHistory"
    | "MentionEveryone"
    | "UseExternalEmojis"
    | "Connect" | "Speak"
    | "MuteMembers"
    | "DeafenMembers"
    | "MoveMembers" | "UseVad"
    | "ChangeNickname"
    | "ManageNicknames"
    | "ManageRoles"
    | "ManageWebhooks"
    | "ManageExpressions"
    | "ManageThreads"
    | "CreatePublicThreads"
    | "CreatePrivateThreads"
    | "UseExternalStickers"
    | "SendMessagesInThreads"
    | "ModerateMembers"
    | "CreateExpressions"
    | "PinMessages"
    | "BypassSlowmode"
    | "UpdateRtcRegion"
    | "ViewChannelMembers")[]
): boolean

Parameters

bits
bigint
names
readonly (
    | "CreateInstantInvite" | "KickMembers" | "BanMembers"
    | "Administrator" | "ManageChannels" | "ManageGuild"
    | "AddReactions" | "ViewAuditLog" | "PrioritySpeaker" | "Stream"
    | "ViewChannel" | "SendMessages" | "SendTtsMessages"
    | "ManageMessages" | "EmbedLinks" | "AttachFiles"
    | "ReadMessageHistory" | "MentionEveryone" | "UseExternalEmojis"
    | "Connect" | "Speak" | "MuteMembers" | "DeafenMembers"
    | "MoveMembers" | "UseVad" | "ChangeNickname"
    | "ManageNicknames" | "ManageRoles" | "ManageWebhooks"
    | "ManageExpressions" | "ManageThreads" | "CreatePublicThreads"
    | "CreatePrivateThreads" | "UseExternalStickers"
    | "SendMessagesInThreads" | "ModerateMembers"
    | "CreateExpressions" | "PinMessages" | "BypassSlowmode"
    | "UpdateRtcRegion" | "ViewChannelMembers")[]readonly (
  | "CreateInstantInvite"
  | "KickMembers" | "BanMembers"
  | "Administrator" | "ManageChannels"
  | "ManageGuild" | "AddReactions"
  | "ViewAuditLog" | "PrioritySpeaker"
  | "Stream" | "ViewChannel"
  | "SendMessages" | "SendTtsMessages"
  | "ManageMessages" | "EmbedLinks"
  | "AttachFiles"
  | "ReadMessageHistory"
  | "MentionEveryone"
  | "UseExternalEmojis" | "Connect"
  | "Speak" | "MuteMembers"
  | "DeafenMembers" | "MoveMembers"
  | "UseVad" | "ChangeNickname"
  | "ManageNicknames" | "ManageRoles"
  | "ManageWebhooks"
  | "ManageExpressions"
  | "ManageThreads"
  | "CreatePublicThreads"
  | "CreatePrivateThreads"
  | "UseExternalStickers"
  | "SendMessagesInThreads"
  | "ModerateMembers"
  | "CreateExpressions"
  | "PinMessages" | "BypassSlowmode"
  | "UpdateRtcRegion"
  | "ViewChannelMembers")[]
Returns
boolean

hasAny#

Return true if bits contains at least one requested permission, or false for an empty names array

Every name is validated even after finding a match. Throws HelperError for invalid bits or unknown names

hasAny(
    bits: bigint,
    names: readonly (
        | "CreateInstantInvite" | "KickMembers" | "BanMembers"
        | "Administrator" | "ManageChannels" | "ManageGuild"
        | "AddReactions" | "ViewAuditLog" | "PrioritySpeaker"
        | "Stream" | "ViewChannel" | "SendMessages"
        | "SendTtsMessages" | "ManageMessages" | "EmbedLinks"
        | "AttachFiles" | "ReadMessageHistory" | "MentionEveryone"
        | "UseExternalEmojis" | "Connect" | "Speak" | "MuteMembers"
        | "DeafenMembers" | "MoveMembers" | "UseVad"
        | "ChangeNickname" | "ManageNicknames" | "ManageRoles"
        | "ManageWebhooks" | "ManageExpressions" | "ManageThreads"
        | "CreatePublicThreads" | "CreatePrivateThreads"
        | "UseExternalStickers" | "SendMessagesInThreads"
        | "ModerateMembers" | "CreateExpressions" | "PinMessages"
        | "BypassSlowmode" | "UpdateRtcRegion"
        | "ViewChannelMembers")[]
): booleanhasAny(
  bits: bigint,
  names: readonly (
    | "CreateInstantInvite"
    | "KickMembers" | "BanMembers"
    | "Administrator"
    | "ManageChannels"
    | "ManageGuild"
    | "AddReactions"
    | "ViewAuditLog"
    | "PrioritySpeaker" | "Stream"
    | "ViewChannel"
    | "SendMessages"
    | "SendTtsMessages"
    | "ManageMessages"
    | "EmbedLinks" | "AttachFiles"
    | "ReadMessageHistory"
    | "MentionEveryone"
    | "UseExternalEmojis"
    | "Connect" | "Speak"
    | "MuteMembers"
    | "DeafenMembers"
    | "MoveMembers" | "UseVad"
    | "ChangeNickname"
    | "ManageNicknames"
    | "ManageRoles"
    | "ManageWebhooks"
    | "ManageExpressions"
    | "ManageThreads"
    | "CreatePublicThreads"
    | "CreatePrivateThreads"
    | "UseExternalStickers"
    | "SendMessagesInThreads"
    | "ModerateMembers"
    | "CreateExpressions"
    | "PinMessages"
    | "BypassSlowmode"
    | "UpdateRtcRegion"
    | "ViewChannelMembers")[]
): boolean

Parameters

bits
bigint
names
readonly (
    | "CreateInstantInvite" | "KickMembers" | "BanMembers"
    | "Administrator" | "ManageChannels" | "ManageGuild"
    | "AddReactions" | "ViewAuditLog" | "PrioritySpeaker" | "Stream"
    | "ViewChannel" | "SendMessages" | "SendTtsMessages"
    | "ManageMessages" | "EmbedLinks" | "AttachFiles"
    | "ReadMessageHistory" | "MentionEveryone" | "UseExternalEmojis"
    | "Connect" | "Speak" | "MuteMembers" | "DeafenMembers"
    | "MoveMembers" | "UseVad" | "ChangeNickname"
    | "ManageNicknames" | "ManageRoles" | "ManageWebhooks"
    | "ManageExpressions" | "ManageThreads" | "CreatePublicThreads"
    | "CreatePrivateThreads" | "UseExternalStickers"
    | "SendMessagesInThreads" | "ModerateMembers"
    | "CreateExpressions" | "PinMessages" | "BypassSlowmode"
    | "UpdateRtcRegion" | "ViewChannelMembers")[]readonly (
  | "CreateInstantInvite"
  | "KickMembers" | "BanMembers"
  | "Administrator" | "ManageChannels"
  | "ManageGuild" | "AddReactions"
  | "ViewAuditLog" | "PrioritySpeaker"
  | "Stream" | "ViewChannel"
  | "SendMessages" | "SendTtsMessages"
  | "ManageMessages" | "EmbedLinks"
  | "AttachFiles"
  | "ReadMessageHistory"
  | "MentionEveryone"
  | "UseExternalEmojis" | "Connect"
  | "Speak" | "MuteMembers"
  | "DeafenMembers" | "MoveMembers"
  | "UseVad" | "ChangeNickname"
  | "ManageNicknames" | "ManageRoles"
  | "ManageWebhooks"
  | "ManageExpressions"
  | "ManageThreads"
  | "CreatePublicThreads"
  | "CreatePrivateThreads"
  | "UseExternalStickers"
  | "SendMessagesInThreads"
  | "ModerateMembers"
  | "CreateExpressions"
  | "PinMessages" | "BypassSlowmode"
  | "UpdateRtcRegion"
  | "ViewChannelMembers")[]
Returns
boolean

inspect#

Return a frozen object listing present known names and any remaining flags as unknownBits

Names follow Permissions declaration order. Unknown flags are preserved, and Administrator does not add other names. Throws HelperError for bits outside the unsigned 64-bit range

inspect(bits: bigint): PermissionBitInspectioninspect(
  bits: bigint
): PermissionBitInspection

Parameters

bits
bigint

label#

Return the English label that Fluxer's own app shows for a permission, such as "Manage community" for ManageGuild and "Time out members" for ModerateMembers

Use it to show a permission to people, because the identifier is not a readable name. The labels are fixed English text and are not translated. They are Fluxer's community-scope titles. Inside a channel's permission screen, Fluxer titles ManageChannels "Manage channel" and ManageRoles "Manage permissions", and every other title is the same there. Throws HelperError for an unknown permission name

label(
    name:
        | "CreateInstantInvite" | "KickMembers" | "BanMembers"
        | "Administrator" | "ManageChannels" | "ManageGuild"
        | "AddReactions" | "ViewAuditLog" | "PrioritySpeaker"
        | "Stream" | "ViewChannel" | "SendMessages"
        | "SendTtsMessages" | "ManageMessages" | "EmbedLinks"
        | "AttachFiles" | "ReadMessageHistory" | "MentionEveryone"
        | "UseExternalEmojis" | "Connect" | "Speak" | "MuteMembers"
        | "DeafenMembers" | "MoveMembers" | "UseVad"
        | "ChangeNickname" | "ManageNicknames" | "ManageRoles"
        | "ManageWebhooks" | "ManageExpressions" | "ManageThreads"
        | "CreatePublicThreads" | "CreatePrivateThreads"
        | "UseExternalStickers" | "SendMessagesInThreads"
        | "ModerateMembers" | "CreateExpressions" | "PinMessages"
        | "BypassSlowmode" | "UpdateRtcRegion"
        | "ViewChannelMembers"
): stringlabel(
  name:
    | "CreateInstantInvite"
    | "KickMembers" | "BanMembers"
    | "Administrator"
    | "ManageChannels"
    | "ManageGuild"
    | "AddReactions"
    | "ViewAuditLog"
    | "PrioritySpeaker" | "Stream"
    | "ViewChannel"
    | "SendMessages"
    | "SendTtsMessages"
    | "ManageMessages"
    | "EmbedLinks" | "AttachFiles"
    | "ReadMessageHistory"
    | "MentionEveryone"
    | "UseExternalEmojis"
    | "Connect" | "Speak"
    | "MuteMembers"
    | "DeafenMembers"
    | "MoveMembers" | "UseVad"
    | "ChangeNickname"
    | "ManageNicknames"
    | "ManageRoles"
    | "ManageWebhooks"
    | "ManageExpressions"
    | "ManageThreads"
    | "CreatePublicThreads"
    | "CreatePrivateThreads"
    | "UseExternalStickers"
    | "SendMessagesInThreads"
    | "ModerateMembers"
    | "CreateExpressions"
    | "PinMessages"
    | "BypassSlowmode"
    | "UpdateRtcRegion"
    | "ViewChannelMembers"
): string

Parameters

name
| "CreateInstantInvite" | "KickMembers" | "BanMembers"
| "Administrator" | "ManageChannels" | "ManageGuild"
| "AddReactions" | "ViewAuditLog" | "PrioritySpeaker" | "Stream"
| "ViewChannel" | "SendMessages" | "SendTtsMessages"
| "ManageMessages" | "EmbedLinks" | "AttachFiles"
| "ReadMessageHistory" | "MentionEveryone" | "UseExternalEmojis"
| "Connect" | "Speak" | "MuteMembers" | "DeafenMembers"
| "MoveMembers" | "UseVad" | "ChangeNickname" | "ManageNicknames"
| "ManageRoles" | "ManageWebhooks" | "ManageExpressions"
| "ManageThreads" | "CreatePublicThreads" | "CreatePrivateThreads"
| "UseExternalStickers" | "SendMessagesInThreads"
| "ModerateMembers" | "CreateExpressions" | "PinMessages"
| "BypassSlowmode" | "UpdateRtcRegion" | "ViewChannelMembers"| "CreateInstantInvite"
| "KickMembers" | "BanMembers"
| "Administrator" | "ManageChannels"
| "ManageGuild" | "AddReactions"
| "ViewAuditLog" | "PrioritySpeaker"
| "Stream" | "ViewChannel"
| "SendMessages" | "SendTtsMessages"
| "ManageMessages" | "EmbedLinks"
| "AttachFiles" | "ReadMessageHistory"
| "MentionEveryone"
| "UseExternalEmojis" | "Connect"
| "Speak" | "MuteMembers"
| "DeafenMembers" | "MoveMembers"
| "UseVad" | "ChangeNickname"
| "ManageNicknames" | "ManageRoles"
| "ManageWebhooks"
| "ManageExpressions"
| "ManageThreads"
| "CreatePublicThreads"
| "CreatePrivateThreads"
| "UseExternalStickers"
| "SendMessagesInThreads"
| "ModerateMembers"
| "CreateExpressions" | "PinMessages"
| "BypassSlowmode" | "UpdateRtcRegion"
| "ViewChannelMembers"
Returns
string

missing#

List requested permissions absent from bits, in the order first requested and without duplicates

Returns a frozen array, empty if nothing is missing, and input arrays are not changed. Throws HelperError for invalid bits or unknown names

missing(
    bits: bigint,
    names: readonly (
        | "CreateInstantInvite" | "KickMembers" | "BanMembers"
        | "Administrator" | "ManageChannels" | "ManageGuild"
        | "AddReactions" | "ViewAuditLog" | "PrioritySpeaker"
        | "Stream" | "ViewChannel" | "SendMessages"
        | "SendTtsMessages" | "ManageMessages" | "EmbedLinks"
        | "AttachFiles" | "ReadMessageHistory" | "MentionEveryone"
        | "UseExternalEmojis" | "Connect" | "Speak" | "MuteMembers"
        | "DeafenMembers" | "MoveMembers" | "UseVad"
        | "ChangeNickname" | "ManageNicknames" | "ManageRoles"
        | "ManageWebhooks" | "ManageExpressions" | "ManageThreads"
        | "CreatePublicThreads" | "CreatePrivateThreads"
        | "UseExternalStickers" | "SendMessagesInThreads"
        | "ModerateMembers" | "CreateExpressions" | "PinMessages"
        | "BypassSlowmode" | "UpdateRtcRegion"
        | "ViewChannelMembers")[]
): readonly (
    | "CreateInstantInvite" | "KickMembers" | "BanMembers"
    | "Administrator" | "ManageChannels" | "ManageGuild"
    | "AddReactions" | "ViewAuditLog" | "PrioritySpeaker" | "Stream"
    | "ViewChannel" | "SendMessages" | "SendTtsMessages"
    | "ManageMessages" | "EmbedLinks" | "AttachFiles"
    | "ReadMessageHistory" | "MentionEveryone" | "UseExternalEmojis"
    | "Connect" | "Speak" | "MuteMembers" | "DeafenMembers"
    | "MoveMembers" | "UseVad" | "ChangeNickname"
    | "ManageNicknames" | "ManageRoles" | "ManageWebhooks"
    | "ManageExpressions" | "ManageThreads" | "CreatePublicThreads"
    | "CreatePrivateThreads" | "UseExternalStickers"
    | "SendMessagesInThreads" | "ModerateMembers"
    | "CreateExpressions" | "PinMessages" | "BypassSlowmode"
    | "UpdateRtcRegion" | "ViewChannelMembers")[]missing(
  bits: bigint,
  names: readonly (
    | "CreateInstantInvite"
    | "KickMembers" | "BanMembers"
    | "Administrator"
    | "ManageChannels"
    | "ManageGuild"
    | "AddReactions"
    | "ViewAuditLog"
    | "PrioritySpeaker" | "Stream"
    | "ViewChannel"
    | "SendMessages"
    | "SendTtsMessages"
    | "ManageMessages"
    | "EmbedLinks" | "AttachFiles"
    | "ReadMessageHistory"
    | "MentionEveryone"
    | "UseExternalEmojis"
    | "Connect" | "Speak"
    | "MuteMembers"
    | "DeafenMembers"
    | "MoveMembers" | "UseVad"
    | "ChangeNickname"
    | "ManageNicknames"
    | "ManageRoles"
    | "ManageWebhooks"
    | "ManageExpressions"
    | "ManageThreads"
    | "CreatePublicThreads"
    | "CreatePrivateThreads"
    | "UseExternalStickers"
    | "SendMessagesInThreads"
    | "ModerateMembers"
    | "CreateExpressions"
    | "PinMessages"
    | "BypassSlowmode"
    | "UpdateRtcRegion"
    | "ViewChannelMembers")[]
): readonly (
  | "CreateInstantInvite"
  | "KickMembers" | "BanMembers"
  | "Administrator"
  | "ManageChannels"
  | "ManageGuild" | "AddReactions"
  | "ViewAuditLog"
  | "PrioritySpeaker" | "Stream"
  | "ViewChannel" | "SendMessages"
  | "SendTtsMessages"
  | "ManageMessages" | "EmbedLinks"
  | "AttachFiles"
  | "ReadMessageHistory"
  | "MentionEveryone"
  | "UseExternalEmojis" | "Connect"
  | "Speak" | "MuteMembers"
  | "DeafenMembers" | "MoveMembers"
  | "UseVad" | "ChangeNickname"
  | "ManageNicknames"
  | "ManageRoles"
  | "ManageWebhooks"
  | "ManageExpressions"
  | "ManageThreads"
  | "CreatePublicThreads"
  | "CreatePrivateThreads"
  | "UseExternalStickers"
  | "SendMessagesInThreads"
  | "ModerateMembers"
  | "CreateExpressions"
  | "PinMessages"
  | "BypassSlowmode"
  | "UpdateRtcRegion"
  | "ViewChannelMembers")[]

Parameters

bits
bigint
names
readonly (
    | "CreateInstantInvite" | "KickMembers" | "BanMembers"
    | "Administrator" | "ManageChannels" | "ManageGuild"
    | "AddReactions" | "ViewAuditLog" | "PrioritySpeaker" | "Stream"
    | "ViewChannel" | "SendMessages" | "SendTtsMessages"
    | "ManageMessages" | "EmbedLinks" | "AttachFiles"
    | "ReadMessageHistory" | "MentionEveryone" | "UseExternalEmojis"
    | "Connect" | "Speak" | "MuteMembers" | "DeafenMembers"
    | "MoveMembers" | "UseVad" | "ChangeNickname"
    | "ManageNicknames" | "ManageRoles" | "ManageWebhooks"
    | "ManageExpressions" | "ManageThreads" | "CreatePublicThreads"
    | "CreatePrivateThreads" | "UseExternalStickers"
    | "SendMessagesInThreads" | "ModerateMembers"
    | "CreateExpressions" | "PinMessages" | "BypassSlowmode"
    | "UpdateRtcRegion" | "ViewChannelMembers")[]readonly (
  | "CreateInstantInvite"
  | "KickMembers" | "BanMembers"
  | "Administrator" | "ManageChannels"
  | "ManageGuild" | "AddReactions"
  | "ViewAuditLog" | "PrioritySpeaker"
  | "Stream" | "ViewChannel"
  | "SendMessages" | "SendTtsMessages"
  | "ManageMessages" | "EmbedLinks"
  | "AttachFiles"
  | "ReadMessageHistory"
  | "MentionEveryone"
  | "UseExternalEmojis" | "Connect"
  | "Speak" | "MuteMembers"
  | "DeafenMembers" | "MoveMembers"
  | "UseVad" | "ChangeNickname"
  | "ManageNicknames" | "ManageRoles"
  | "ManageWebhooks"
  | "ManageExpressions"
  | "ManageThreads"
  | "CreatePublicThreads"
  | "CreatePrivateThreads"
  | "UseExternalStickers"
  | "SendMessagesInThreads"
  | "ModerateMembers"
  | "CreateExpressions"
  | "PinMessages" | "BypassSlowmode"
  | "UpdateRtcRegion"
  | "ViewChannelMembers")[]
Returns
readonly (
    | "CreateInstantInvite" | "KickMembers" | "BanMembers"
    | "Administrator" | "ManageChannels" | "ManageGuild"
    | "AddReactions" | "ViewAuditLog" | "PrioritySpeaker" | "Stream"
    | "ViewChannel" | "SendMessages" | "SendTtsMessages"
    | "ManageMessages" | "EmbedLinks" | "AttachFiles"
    | "ReadMessageHistory" | "MentionEveryone" | "UseExternalEmojis"
    | "Connect" | "Speak" | "MuteMembers" | "DeafenMembers"
    | "MoveMembers" | "UseVad" | "ChangeNickname"
    | "ManageNicknames" | "ManageRoles" | "ManageWebhooks"
    | "ManageExpressions" | "ManageThreads" | "CreatePublicThreads"
    | "CreatePrivateThreads" | "UseExternalStickers"
    | "SendMessagesInThreads" | "ModerateMembers"
    | "CreateExpressions" | "PinMessages" | "BypassSlowmode"
    | "UpdateRtcRegion" | "ViewChannelMembers")[]readonly (
  | "CreateInstantInvite"
  | "KickMembers" | "BanMembers"
  | "Administrator" | "ManageChannels"
  | "ManageGuild" | "AddReactions"
  | "ViewAuditLog" | "PrioritySpeaker"
  | "Stream" | "ViewChannel"
  | "SendMessages" | "SendTtsMessages"
  | "ManageMessages" | "EmbedLinks"
  | "AttachFiles"
  | "ReadMessageHistory"
  | "MentionEveryone"
  | "UseExternalEmojis" | "Connect"
  | "Speak" | "MuteMembers"
  | "DeafenMembers" | "MoveMembers"
  | "UseVad" | "ChangeNickname"
  | "ManageNicknames" | "ManageRoles"
  | "ManageWebhooks"
  | "ManageExpressions"
  | "ManageThreads"
  | "CreatePublicThreads"
  | "CreatePrivateThreads"
  | "UseExternalStickers"
  | "SendMessagesInThreads"
  | "ModerateMembers"
  | "CreateExpressions"
  | "PinMessages" | "BypassSlowmode"
  | "UpdateRtcRegion"
  | "ViewChannelMembers")[]

patchOverwrite#

Change some permissions of a channel overwrite's allow and deny bits and keep the rest, for channels.setPermissionOverwrite, which replaces both bit sets

current is the overwrite as read, or undefined when there is none, which counts as nothing allowed or denied. In change, allow sets the permissions in allow and clears them from deny, deny does the reverse, and inherit clears them from both. Every other bit stays as it was, including bits without a known name. Returns a frozen object with the new allow and deny. Throws HelperError when a permission is in more than one list, a name is unknown, change has another key or current holds bits outside the unsigned 64-bit range. An overwrite with both allow and deny at 0n has no effect, so remove it with channels.removePermissionOverwrite. An overwrite read from Fluxer can carry bit 63, which cannot be written back, and Fluxer can still refuse bits that the bot itself lacks

patchOverwrite(
    current:
        | Pick<PermissionOverwrite, "allow" | "deny">
        | undefined,
    change: OverwritePatch
): Readonly<Pick<PermissionOverwrite, "allow" | "deny">>patchOverwrite(
  current:
    | Pick<
        PermissionOverwrite,
        "allow" | "deny"
      >
    | undefined,
  change: OverwritePatch
): Readonly<
  Pick<
    PermissionOverwrite,
    "allow" | "deny"
  >
>

Parameters

current
Pick<PermissionOverwrite, "allow" | "deny"> | undefined| Pick<
    PermissionOverwrite,
    "allow" | "deny"
  >
| undefined
Returns
Readonly<Pick<PermissionOverwrite, "allow" | "deny">>Readonly<
  Pick<
    PermissionOverwrite,
    "allow" | "deny"
  >
>
import { permissionBits } from "@neontechspace/fluxerly"
export async function muteChannelExample(client, channelId, current) {
    const { allow, deny } = permissionBits.patchOverwrite(current, {
        deny: ["SendMessages", "AddReactions"],
        inherit: ["ViewChannel"],
    })
    return await client.channels.setPermissionOverwrite(channelId, { id: "20", type: "role", allow, deny })
}
import { permissionBits, type Client, type PermissionOverwrite } from "@neontechspace/fluxerly"
export async function muteChannelExample(
    client: Client,
    channelId: string,
    current: PermissionOverwrite | undefined,
) {
    const { allow, deny } = permissionBits.patchOverwrite(current, {
        deny: ["SendMessages", "AddReactions"],
        inherit: ["ViewChannel"],
    })
    return await client.channels.setPermissionOverwrite(channelId, { id: "20", type: "role", allow, deny })
}

refusedGrants#

Return the permission bits that Fluxer would refuse when an overwrite changes from current to next, so the change can be checked before the request is sent

Unless the bot has Administrator, Fluxer lets it allow, or stop denying, only permissions it has in the overwrite's channel, and answers missingPermissions otherwise. Removing an overwrite stops all of its denies. Pass the overwrite as read as current and the one to write as next, with undefined for no overwrite, so a next of undefined is a removal. Pass the bot's permission bits in that channel as held, such as the result of permissions.fetch with a channelId or an entry of permissions.fetchChannels. Returns 0n when nothing would be refused. That is always the case when held includes Administrator, and when the change only denies bits or stops allowing them. One call covers one overwrite. For channels.edit with a new list, call it for each target ID in either list. For a category move with syncPermissionsOnMove, call it for each target ID in the channel's or the category's overwrites, with the channel's bits. For channels.create, pass undefined as current and the parent category's bits as held, or the community-wide bits when there is no parent, because Fluxer checks only the allow bits there. Throws HelperError when an overwrite or held has the wrong type or bits outside the unsigned 64-bit range

refusedGrants(
    current:
        | Pick<PermissionOverwrite, "allow" | "deny">
        | undefined,
    next: Pick<PermissionOverwrite, "allow" | "deny"> | undefined,
    held: bigint
): bigintrefusedGrants(
  current:
    | Pick<
        PermissionOverwrite,
        "allow" | "deny"
      >
    | undefined,
  next:
    | Pick<
        PermissionOverwrite,
        "allow" | "deny"
      >
    | undefined,
  held: bigint
): bigint

Parameters

current
Pick<PermissionOverwrite, "allow" | "deny"> | undefined| Pick<
    PermissionOverwrite,
    "allow" | "deny"
  >
| undefined
next
Pick<PermissionOverwrite, "allow" | "deny"> | undefined| Pick<
    PermissionOverwrite,
    "allow" | "deny"
  >
| undefined
held
bigint
Returns
bigint
import { permissionBits } from "@neontechspace/fluxerly"
export async function allowTtsExample(client, guildId, channelId, botId, current) {
    const held = await client.permissions.fetch({ guildId, userId: botId, channelId })
    if (held.isErr())
        return held
    const next = permissionBits.patchOverwrite(current, { allow: ["SendTtsMessages"] })
    const refused = permissionBits.refusedGrants(current, next, held.value)
    if (refused !== 0n)
        return permissionBits.inspect(refused).names
    return await client.channels.setPermissionOverwrite(channelId, { id: "20", type: "role", ...next })
}
import { permissionBits, type Client, type PermissionOverwrite } from "@neontechspace/fluxerly"
export async function allowTtsExample(
    client: Client,
    guildId: string,
    channelId: string,
    botId: string,
    current: PermissionOverwrite | undefined,
) {
    const held = await client.permissions.fetch({ guildId, userId: botId, channelId })
    if (held.isErr()) return held
    const next = permissionBits.patchOverwrite(current, { allow: ["SendTtsMessages"] })
    const refused = permissionBits.refusedGrants(current, next, held.value)
    if (refused !== 0n) return permissionBits.inspect(refused).names
    return await client.channels.setPermissionOverwrite(channelId, { id: "20", type: "role", ...next })
}

sameOverwrites#

Return whether two overwrite lists are equal the way Fluxer compares them: The same target IDs, and for each ID the same type, allow and deny

Order and other fields of the entries are ignored. A channel whose overwrites equal its category's is synced with it. When channels.edit, channels.setPermissionOverwrite or channels.removePermissionOverwrite changes the category's overwrites, Fluxer copies the change to exactly those children, with no opt-out. Compare each child with the category before the change to learn which channels it will rewrite. Two empty lists are equal, so a category without overwrites also syncs every child without overwrites. Throws HelperError for a value that is not an array, an entry with an invalid ID, type or bits, or a list that names the same ID twice. Fluxer rejects duplicate IDs on write, so a list read from Fluxer never has one

sameOverwrites(
    first: readonly PermissionOverwrite[],
    second: readonly PermissionOverwrite[]
): booleansameOverwrites(
  first:
    readonly PermissionOverwrite[],
  second:
    readonly PermissionOverwrite[]
): boolean

Parameters

first
readonly PermissionOverwrite[]
second
readonly PermissionOverwrite[]
Returns
boolean

toDecimal#

Convert unsigned 64-bit bigint permission bits to the decimal string used in Fluxer JSON requests and URLs

Throws HelperError for values outside that range

toDecimal(bits: bigint): string

Parameters

bits
bigint
Returns
string

PermissionName#

A key of Permissions, such as "ManageMessages", accepted by the named permissionBits helpers

type PermissionName = keyof typeof Permissionstype PermissionName =
    keyof typeof Permissions