Fluxer API Docs

Quickstart

Get up and running with the Fluxer API quickly

This guide walks you through building a tiny Fluxer bot using JavaScript. Fluxer works with any language that can speak HTTP, but JavaScript keeps the examples short and familiar.

Fluxer's API is intentionally close to the Discord API. If you've built Discord bots before, you'll recognize most of the shapes here. In fact, many Discord libraries work with Fluxer with only a few tweaks.

For this quickstart, we'll use discord.js and its core packages:

Prerequisites

Before you start, make sure you have:

Step 1: Set Up Your Project

  1. Create a new directory and move into it:
    mkdir fluxer-quickstart
    cd fluxer-quickstart
  2. Initialize a new Node.js project:
    echo '{
      "name": "fluxer-quickstart",
      "version": "1.0.0",
      "type": "module",
      "main": "bot.js"
    }' > package.json
  3. Install the required packages:
    npm install @discordjs/core @discordjs/rest @discordjs/ws

Step 2: Create a Fluxer Application

  1. Open the Fluxer web or desktop app and log in.
  2. Press the cogwheel in the bottom-left to open User Settings, then go to Developer Applications.
  3. Create a new application. Name it something awesome.
  4. Generate a bot token for that application and copy it somewhere safe — we'll use it as FLUXER_BOT_TOKEN.
  5. Press "Invite Bot" and select a community where you have the "Manage Community" permission.

Step 3: Write Your Bot Code

Create a file named bot.js in your project directory and add:

import {Client, GatewayDispatchEvents} from '@discordjs/core';
import {REST} from '@discordjs/rest';
import {WebSocketManager} from '@discordjs/ws';

const rest = new REST({api: 'https://api.fluxer.app', version: '1'}).setToken(process.env.FLUXER_BOT_TOKEN);

const gateway = new WebSocketManager({
	intents: 0,
	rest,
	token: process.env.FLUXER_BOT_TOKEN,
	version: '1',
});

export const client = new Client({rest, gateway});

client.on(GatewayDispatchEvents.MessageCreate, async ({api, data}) => {
	if (data.content === 'ping') {
		await api.channels.createMessage(data.channel_id, {
			content: 'pong',
		});
	}
});

client.on(GatewayDispatchEvents.Ready, (data) => {
	console.log(`Logged in as ${data.user.username}#${data.user.discriminator}`);
});

gateway.connect();

This does three things:

  • Connects to the Fluxer gateway using your bot token
  • Listens for new messages
  • Replies with pong whenever someone sends ping in a channel your bot can see

Step 4: Run Your Bot

  1. Set your bot token as an environment variable. On macOS/Linux:
    export FLUXER_BOT_TOKEN="your_bot_token_here"
    On Windows (Command Prompt):
    set FLUXER_BOT_TOKEN="your_bot_token_here"
  2. Start the bot:
    node bot.js

If everything is wired up correctly, you should see a log line with your bot's username. Try sending ping in a channel where the bot has access — it should answer with pong.

Pat Yourself on the Back

Nice work. You've just:

  • Created a Fluxer application
  • Wired up discord.js core packages to talk to the Fluxer API
  • Built and run a simple message-handling bot

From here, you can:

  • Browse the Fluxer API reference
  • Explore all events in the Gateway Events documentation
  • See what other API endpoints are available
  • Start adding commands, routing, and whatever else your bot needs

Happy coding!

On this page