LittleSpace Network Developers
Sign in

Permissions

There are two sides to permissions: what your bot is allowed to do, and what the person using a command is allowed to do.

#What your bot needs

The bot gets its permissions from the invite link and from roles in the community. Ask for only what it uses. The invite link builder has presets for common bots.

If the bot is missing a permission, the call fails with a 403 and a code like MISSING_PERMISSIONS. Catch it and tell the person what’s wrong:

JavaScript
try {
  await bot.rest.deleteMessage(message.channel_id, message.id);
} catch (err) {
  if (err.status === 403) await reply('I need **Manage messages** in this channel to do that.');
  else throw err;
}

#What a member can do

bot.permissionsFor(message) works out what the author of a message can do in that channel. It counts their roles, the channel’s overrides, and whether they own the community:

JavaScript
import { Permissions, hasPermission } from '@littlespace/fluxkit';

const perms = bot.permissionsFor(message);
if (hasPermission(perms, Permissions.BAN_MEMBERS)) {
  // they can ban people here
}

It returns null in DMs. hasPermission treats Administrator as having everything.

#Permission names

Use the names from Permissions rather than numbers. Some of Fluxer’s values are bigger than JavaScript’s normal number limit, so they’re BigInts.

NameLets someone
VIEW_CHANNELSee the channel
SEND_MESSAGESSend messages
READ_MESSAGE_HISTORYRead older messages
EMBED_LINKSSend embeds
ATTACH_FILESUpload files
ADD_REACTIONSAdd new reactions
MANAGE_MESSAGESDelete other people’s messages
PIN_MESSAGESPin messages
KICK_MEMBERSKick people
BAN_MEMBERSBan people
MODERATE_MEMBERSTime people out
MANAGE_ROLESGive and take roles below their own
VIEW_AUDIT_LOGRead the audit log
MANAGE_GUILDChange community settings and add bots
ADMINISTRATOREverything

The invite link builder shows every permission Fluxer has.

#Roles and the order they’re in

Like Discord, a bot can only give or take roles that sit below its own highest role. If a reaction-role bot can’t hand out a role, move the bot’s role above it in the community’s role settings.