Skip to content

fluxerjs/core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

133 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@fluxerjs/core

CI CodeQL npm version License Socket Badge

SDK for building bots on Fluxer.

Install

pnpm add @fluxerjs/core

Usage

import { Client, Events } from '@fluxerjs/core';

const client = new Client({ intents: 0 });

client.on(Events.Ready, () => console.log('Ready'));
client.on(Events.MessageCreate, async (m) => {
  if (m.content === '!ping') await m.reply('Pong');
});

await client.login(process.env.FLUXER_BOT_TOKEN);

Self-hosted / multiple instances

One Client = one Fluxer instance (token, REST, gateway, caches, CDN/invite URLs). Each instance needs its own bot token.

Beta: ClientCluster can add/remove/restart runtimes without restarting the process. The API may change; constructing a cluster emits a FluxerClientClusterBeta warning. restart(id, { token }) requires re-supplying the instance token (never stored).

import { ClientCluster, ClientClusterEvents, Events } from '@fluxerjs/core';
// or: import { ClientCluster } from '@fluxerjs/core/cluster';

const cluster = new ClientCluster({
  configure(runtime) {
    runtime.client.on(Events.MessageCreate, async (m) => {
      if (m.content === '!ping') await m.reply(`Pong from ${runtime.id}`);
    });
  },
});

await cluster.add({ id: 'hosted', token: process.env.FLUXER_BOT_TOKEN });
await cluster.add({
  id: 'self',
  token: process.env.SELFHOST_BOT_TOKEN, // must be issued by the self-hosted instance
  discovery: 'https://api.my.instance',
});

// Later — no process restart
await cluster.restart('self', { token: process.env.SELFHOST_BOT_TOKEN });
await cluster.remove('self');

You can still manage raw Client instances yourself. See examples/multi-instance-bot.js and the multi-instance guide.

Documentation

The docs site (apps/docs) is a Next.js app: MDX guides, OpenAPI REST reference, and SDK API docs from a custom docgen (TypeScript Compiler API → public/api/main.json).

From the repo root:

# Dev server — http://localhost:3333
pnpm run docs:dev

# Build packages + generate docs + Next build
pnpm run docs:build

# Preview the production build
pnpm run docs:preview

What each command does:

  • docs:dev — Next.js on port 3333
  • docs:build — Generates API docs JSON, then builds the Next.js docs site (via turbo)
  • docs:previewnext start on port 3333

License

Apache-2.0

About

Resources

License

Code of conduct

Contributing

Security policy

Stars

41 stars

Watchers

1 watching

Forks

Sponsor this project

 

Packages

 
 
 

Contributors