API reference
Everything you can import from @littlespace/fluxkit.
#FluxerClient
JavaScript
const bot = new FluxerClient(options);
| Option | Default | What it does |
|---|
instance | required | The instance’s address, like 'https://littlespace.chat' |
token | required | The bot token. A leading Bot is removed if you include it. |
prefix | '!' | The command prefix, or an array of them |
ignoredEvents | typing and presence | Fluxer events to skip. Pass [] to get everything. |
presence | your saved status | The status to show when the bot connects |
shard | none | [shardId, shardCount] for bots in more than 2,500 communities |
#Methods
| Method | Returns | What it does |
|---|
login() | Promise | Connects. Resolves when the bot is ready, rejects on a bad token. |
destroy() | | Disconnects |
command(name, options?, handler) | the client | Adds a command. See Commands. |
reply(message, content) | Promise<message> | Replies to a message without pinging the author |
permissionsFor(message) | BigInt or null | The author’s permissions in that channel |
channel(guildId, channelId) | channel or null | A cached channel |
#Properties
| Property | What it is |
|---|
user | The bot’s own account, after ready |
guilds | A Map of the communities the bot is in, kept up to date |
rest | The REST client, below |
commands | The command list. commands.list() returns every command. |
endpoints | The instance’s addresses from discovery |
gateway.ping | Milliseconds for the last heartbeat round trip |
#Events
ready, message, commandError, error, debug, raw (name, data), and every Fluxer event by name, such as GUILD_MEMBER_ADD. See Events.
#rest
| Method | What it does |
|---|
sendMessage(channelId, content) | Sends a message. content is a string or a message object. |
editMessage(channelId, messageId, content) | Edits one of the bot’s messages |
deleteMessage(channelId, messageId, reason?) | Deletes a message |
react(channelId, messageId, emoji) | Adds a reaction |
createDM(userId) | Opens a DM channel |
me() | The bot’s own account |
get / post / patch / put / delete(path, ...) | Any route from the Fluxer API. Paths work with or without /v1. |
Every method takes a last options object with reason (shown in the audit log), query and headers.
Failed calls throw a FluxerAPIError with status, code and the response body.
#Other exports
| Export | What it does |
|---|
executeWebhook(url, body) | Posts through a webhook. See Webhooks. |
Permissions | Every permission as a BigInt |
hasPermission(perms, flag) | Whether perms includes flag, counting Administrator |
computePermissions(guild, userId, roleIds, channel?) | Works out permissions by hand |
discover(instance) | Reads an instance’s published addresses |
Commands, splitArgs | The command parser, if you want to use it on its own |
REST, Gateway | The lower-level clients FluxerClient is built from |