LittleSpace Network Developers
Sign in

Events

Commands cover messages that start with !. For everything else, listen for events.

#Messages

message fires for every new message the bot can see, except its own:

JavaScript
bot.on('message', async (message) => {
  if (message.author.bot) return;
  if (/\bbwah\b/i.test(message.content)) {
    await bot.rest.react(message.channel_id, message.id, '🦁');
  }
});

In a community, the message has guild_id and a member object with the author’s roles. In a DM, both are missing.

#Fluxer’s own events

Every event from Fluxer is available by its name:

JavaScript
bot.on('GUILD_MEMBER_ADD', async (member) => {
  const welcome = '1489002177550843905'; // your welcome channel
  await bot.rest.sendMessage(welcome, `Welcome, <@${member.user.id}>! Grab a blanket 🧸`);
});

bot.on('MESSAGE_REACTION_ADD', (r) => {
  console.log(`${r.user_id} reacted ${r.emoji.name} on ${r.message_id}`);
});

The ones bots use most:

EventWhen it happens
MESSAGE_CREATE, MESSAGE_UPDATE, MESSAGE_DELETEA message is sent, edited or deleted
MESSAGE_REACTION_ADD, MESSAGE_REACTION_REMOVESomeone reacts or takes a reaction back
GUILD_MEMBER_ADD, GUILD_MEMBER_REMOVESomeone joins or leaves a community
GUILD_MEMBER_UPDATESomeone’s roles or nickname change
GUILD_BAN_ADD, GUILD_BAN_REMOVESomeone is banned or unbanned
GUILD_CREATE, GUILD_DELETEThe bot joins or leaves a community
CHANNEL_CREATE, CHANNEL_UPDATE, CHANNEL_DELETEChannels change
GUILD_AUDIT_LOG_ENTRY_CREATEAnything lands in the audit log (needs View audit log)

The full list, with what each one contains, is in Fluxer’s Gateway events.

#Events fluxkit skips

To save bandwidth, fluxkit asks Fluxer not to send typing and presence events. If your bot needs them, set the list yourself:

JavaScript
const bot = new FluxerClient({ instance: 'https://littlespace.chat', token, ignoredEvents: [] });

#Startup and connection

EventWhen it happens
readyThe bot is logged in. bot.user and bot.guilds are filled in.
errorSomething stopped the bot for good, like a bad token
debugConnection details, handy while you’re working on the bot
JavaScript
bot.on('debug', (line) => console.log('[fluxer]', line));

If the connection drops, fluxkit reconnects and picks up where it left off, so events that happened while it was gone still arrive.