NEW 📢 Black Friday: our launch offer ends 30 Nov. Up to 70% off your first month on every game!See plans
Black FridayUp to 70% off your first month, ends 30 NovEnds in 6d 12h 58mBlack FridayUp to 70% off your first month, ends 30 NovEnds in 6d 12h 58mBlack FridayUp to 70% off your first month, ends 30 NovEnds in 6d 12h 58m

Make your first Fluxer bot with fluxer.js

Fluxer bot hostingUpdated Nov 10, 20266 min read

A first Fluxer bot takes two files: a package.json that installs fluxer.js (the npm package @fluxerjs/core) and an index.js that logs in with your bot token and answers commands such as !ping. You need Node.js 22.13 or newer and a bot token from Fluxer. Fluxer has no slash commands for bots yet, so commands are ordinary messages that start with a prefix. The bot below is the one we ran on our own servers for this guide, against a test copy of Fluxer's gateway and API (not the live service); it answered !ping, !hello Sam and !HELLO, and ignored everything else.

1. Create the bot in Fluxer

  1. In Fluxer, open User settings, then Applications under Developer, and create an application. Each application has one bot account.
  2. Copy the bot token from Secrets & tokens. It looks like <application id>.<secret> and is shown once. Anyone with it controls your bot: keep it out of your code and out of Git.
  3. Use the OAuth2 URL builder to make an invite link with the bot scope and the Bot permissions it needs (at least viewing channels and sending messages), then open it and pick your community. You need Manage community there.

2. The two files

package.json:

{
  "name": "my-fluxer-bot",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "dependencies": {
    "@fluxerjs/core": "3.3.0"
  }
}

"type": "module" lets you use import and a top-level await, as fluxer.js's own examples do. Pinning the version keeps an update from changing your bot without you knowing; raise it when you have read the fluxer.js changelog.

index.js:

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

const PREFIX = '!';
const client = new Client({ ignoredEvents: ['TYPING_START'] });

client.on(Events.Ready, () => {
  console.log(`Logged in as ${client.user?.username}`);
});

client.on(Events.MessageCreate, async (message) => {
  if (message.author.bot || !message.content) return;

  const parsed = parsePrefixCommand(message.content, PREFIX);
  if (!parsed) return;
  const { command, args } = parsed;

  try {
    if (command === 'ping') {
      await message.reply('Pong!');
    } else if (command === 'hello') {
      await message.reply(`Hello, ${args[0] ?? message.author.username}!`);
    }
  } catch (err) {
    console.error(`Could not answer !${command}: ${err.message}`);
  }
});

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

3. What each part does

  • new Client(...) connects to the main Fluxer service by default. Fluxer has no gateway intents; ignoredEvents asks Fluxer not to send events you do not use. Leave it out and the bot still works.
  • Events.Ready fires once the gateway has accepted the token. The Logged in as line is how you know the bot is online.
  • parsePrefixCommand returns null for a message that does not start with the prefix. Otherwise it gives the command in lowercase (so !HELLO works) and the words after it in args, with their case kept.
  • message.author.bot: ignoring other bots stops two bots from answering each other forever.
  • await message.reply(...) inside try: a reply can fail, for example when the bot may not send messages in that channel. Awaiting it and catching the error puts the reason in your console instead of an unhandled rejection.
  • process.env.FLUXER_BOT_TOKEN: the token comes from the environment, never from the file.

4. Run it

On your computer, in the folder with both files:

npm install
FLUXER_BOT_TOKEN=your-token node index.js

On Windows PowerShell, set the token with $env:FLUXER_BOT_TOKEN="your-token", then run node index.js. Send !ping in a channel the bot can see: it answers Pong! as a reply.

To keep it online when your computer is off, upload the same two files to a bot plan: How to host a Fluxer bot 24/7 has the steps. On PlayNHost you add FLUXER_BOT_TOKEN on the Bot page, pane Environment, with Keep this value secret ticked, and upload the files without node_modules: the server runs npm install itself.

5. If you know discord.js

HabitIn fluxer.js
Intents bitmaskLeave it out (ignored); use ignoredEvents to receive less
Slash commands and interactionsPrefix commands such as !ping; slash commands are on Fluxer's 2026 roadmap
Guild Create for every guild at startup (fluxer.js before 3.1)Startup sends Guild Available, as in discord.js; Guild Create is a guild joined after Ready
.get and .fetchThe same idea: .get(id) reads the cache, .fetch(id) asks the API

A Discord bot token does not work on Fluxer, and a Fluxer token works only on the Fluxer instance that issued it.

If it does not start

  • _FluxerError: Gateway authentication failed (4004). Check the bot token.: the token is wrong or was regenerated. Copy the current one from Secrets & tokens.
  • A [MODULE_TYPELESS_PACKAGE_JSON] warning at start: "type": "module" is missing from package.json. Node.js still runs the file, but add the line to remove the warning.
  • npm warns about the engine, or the bot crashes on start, on an old Node.js: fluxer.js needs Node.js 22.13 or newer. Check with node --version.
  • Online but no answer: the bot cannot view that channel, or the message did not start with !.

PlayNHost is not affiliated with Fluxer, Fluxer Platform AB or the fluxer.js project.

Already hosting it somewhere else? Move your server to us