Basic Bot

Login, handle Ready, and reply to !ping. Start here after install.

Connect, wait for Ready, reply to !ping. client.on is the default. client.events is an optional chainable alias if you want it.

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

const client = new Client();

client.on(Events.Ready, () => console.log('Ready!'));

client.on(Events.MessageCreate, async (message) => {
  if (message.author.bot) return;
  if (message.content === '!ping') {
    await message.reply('Pong!');
  }
});

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

After Ready, client.uptime is milliseconds since that moment (null before). Gateway heartbeat RTT is client.ws.ping (-1 until the first ACK).

Habits that save you pain

Always await replies so a failed send is not a silent unhandled rejection:

javascript
// bad
message.reply('Pong!');

// good
await message.reply('Pong!');

Pass builders straight into options. Do not call .toJSON() yourself:

javascript
await message.reply({ embeds: [embed] });

Ignore other bots unless you have a reason not to. Infinite bot loops are embarrassing.

Next: Prefix commands, then Errors and Caching. Task index: Where do I...?.

Questions?Join the Fluxer community for help with the SDK.Join Fluxer