FNLB Devs

Developer Portal

SDK

SDK Events

fnlb is an event emitter. Import Events from fnlb and pass the enum to fnlb.on or fnlb.once. Names are stable strings such as ready and party:member:message. Party and friend chat arrive as a Message. ready arrives as a Bot. Other events arrive as { bot, ...fields }. Full party meta is not on the event. Call bot.party.meta.get() when you need the schema. See Bots and parties.

import FNLB, { Events } from 'fnlb';

const fnlb = new FNLB();

fnlb.on(Events.Ready, (bot) => {
  console.log(bot.id, bot.displayName);
});

fnlb.on(Events.PartyMemberMessage, async (message) => {
  if (message.content === '!ping') await message.reply('pong');
});

Lifecycle

EventPayloadWhen
Events.ReadyBotThe Fortnite client finished logging this bot in.
Events.Disconnected{ bot, isLogout }The Fortnite client disconnected.
Events.ShardReadyShardA shard process opened the local SDK bridge and can take IPC calls.

Chat

EventPayloadWhen
Events.PartyMemberMessageMessage with channel: 'party'Someone wrote in the bot's party chat.
Events.FriendMessageMessage with channel: 'friend'An Epic friend whispered the bot.

message.bot is the bot that received it. message.author is { id, displayName }. message.reply(text) sends back on the same channel: party chat, or a whisper to the author.

Friends

EventExtra fields
Events.FriendRequest{ id, displayName }
Events.FriendAddedThe user is now on the friend list.
Events.FriendRemovedThe user left the friend list.
Events.FriendOnline / Events.FriendOfflinePresence came online or went offline.
Events.FriendPresencestatus, isJoinable, partySize
Events.UserBlocked / Events.UserUnblockedThe bot blocked or unblocked a user.

Accept or decline a request with bot.acceptFriend and bot.declineFriend. See Chat and commands.

Party

EventExtra fields
Events.PartyInvitepartyId, sender
Events.PartyJoinRequestpartyId, sender
Events.PartyMemberJoined{ member } with cosmetic ids, not the meta schema
Events.PartyMemberLeftThe member who left
Events.PartyMemberKickedThe member who was kicked
Events.PartyMemberPromotedThe new party leader
Events.PartyMemberUpdatedMember summary after a cosmetic or matchmaking tick
Events.PartyUpdateid, size, memberIds
Events.PartyRecreatedThe bot made a new party after the previous one was disbanded

Cosmetics and match

These fire when one field on a member changes. value is the new value and previousValue is the old one, when the client has it.

EventWhat changed
Events.PartyMemberOutfitUpdatedOutfit
Events.PartyMemberEmoteUpdatedEmote, emoji, or jam track
Events.PartyMemberBackpackUpdatedBack bling
Events.PartyMemberPickaxeUpdatedPickaxe
Events.PartyMemberReadinessUpdatedvalue is the new ready boolean
Events.PartyMemberMatchStateUpdatedMatch state

The full list, including payload shapes, is Events in the SDK reference. Chat payloads are Message. The ready payload is Bot.

A listener that acts

Register before start(). ready is the first safe place to touch that bot's party. Invites and friend requests include the sender so you can accept without listing pending friends first.

import FNLB, { Events } from 'fnlb';

const fnlb = new FNLB();

fnlb.on(Events.Ready, async (bot) => {
  console.log(bot.displayName, bot.party.id);
});

fnlb.on(Events.FriendRequest, async ({ bot, id }) => {
  await bot.acceptFriend(id);
});

fnlb.on(Events.PartyInvite, async ({ bot, sender }) => {
  console.log(sender.displayName, 'invited', bot.nickname);
});

fnlb.on(Events.PartyMemberOutfitUpdated, ({ member, value }) => {
  console.log(member.displayName, 'equipped', value);
});

await fnlb.start({
  token: 'FNLB_...',
  categories: ['your-category-id']
});

fnlb.once(Events.Ready, ...) runs for the first bot only. Use on when more than one bot will log in. PartyMemberJoined and PartyMemberUpdated carry a member summary: id, display name, leader, ready, and cosmetic ids. They do not include the meta schema. Read that with bot.party.meta.get() or member.meta.get(), documented in Bots and parties. Cosmetic events are the ones to use when you want to react to a change. Setting an outfit yourself with party.setOutfit also updates the member and can emit PartyMemberOutfitUpdated.

Reference

TopicSymbol
Event namesEvents
Chat messageMessage
Ready botBot
Shard helloShard