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:
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:
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:
| Event | When it happens |
|---|---|
MESSAGE_CREATE, MESSAGE_UPDATE, MESSAGE_DELETE | A message is sent, edited or deleted |
MESSAGE_REACTION_ADD, MESSAGE_REACTION_REMOVE | Someone reacts or takes a reaction back |
GUILD_MEMBER_ADD, GUILD_MEMBER_REMOVE | Someone joins or leaves a community |
GUILD_MEMBER_UPDATE | Someone’s roles or nickname change |
GUILD_BAN_ADD, GUILD_BAN_REMOVE | Someone is banned or unbanned |
GUILD_CREATE, GUILD_DELETE | The bot joins or leaves a community |
CHANNEL_CREATE, CHANNEL_UPDATE, CHANNEL_DELETE | Channels change |
GUILD_AUDIT_LOG_ENTRY_CREATE | Anything 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:
const bot = new FluxerClient({ instance: 'https://littlespace.chat', token, ignoredEvents: [] });#Startup and connection
| Event | When it happens |
|---|---|
ready | The bot is logged in. bot.user and bot.guilds are filled in. |
error | Something stopped the bot for good, like a bad token |
debug | Connection details, handy while you’re working on the bot |
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.