π¦ Installation
Install the latest version via npm install :
Using bun ? Install the latest version via bun install :
π€ Starting a Single Bot
Get started with a single bot using your FNLB API token . Learn more :
import FNLB from 'fnlb' ;
const fnlb = new FNLB ();
await fnlb . start ({
apiToken: 'your-api-token' , // π Replace with your actual token
categories: [ 'your-category-id' ] // Get this from your botβs page
});
π Running Multiple Bots (Same Shard)
Run multiple bots in a single subprocess using the botsPerShard option:
import FNLB from 'fnlb' ;
const fnlb = new FNLB ();
await fnlb . start ({
apiToken: 'your-api-token' ,
categories: [ 'your-category-id' ],
botsPerShard: 10 // π§± Spawns max 10 bots
});
π§© Using Multiple Shards (Subprocesses)
Scale even more by spawning multiple shards (subprocesses) with multiple bots each:
import FNLB from 'fnlb' ;
const fnlb = new FNLB ();
await fnlb . start ({
apiToken: 'your-api-token' ,
categories: [ 'your-category-id' ],
numberOfShards: 2 , // 2 shards π§©
botsPerShard: 10 // max 10 bots per shard π€
});
Total bots: numberOfShards Γ botsPerShard
In this example: 2 Γ 10 = 20 bots max
ποΈ Launching Bots Across Multiple Categories
Want to run bots from different FNLB categories? Just add them to the categories array:
import FNLB from 'fnlb' ;
const fnlb = new FNLB ();
await fnlb . start ({
apiToken: 'your-api-token' ,
categories: [ 'category-id-1' , 'category-id-2' ], // π Multi-category support
numberOfShards: 2 ,
botsPerShard: 10
});
β Stopping All Bots
Shut everything down cleanly using the stop() method:
import FNLB from 'fnlb' ;
const fnlb = new FNLB ();
await fnlb . start ({
apiToken: 'your-api-token' ,
numberOfShards: 2 ,
botsPerShard: 10
});
await fnlb . stop (); // π Stops all shards and bots
π·οΈ Naming Your Cluster
Customize your cluster with a unique name using the clusterName option:
import FNLB from 'fnlb' ;
const fnlb = new FNLB ({ clusterName: 'MyAwesomeCluster' });
await fnlb . start ({
apiToken: 'your-api-token'
});
π Auto-Restart Every Hour (Optional)
Want to keep things fresh? Hereβs how to restart your bots automatically every hour:
import FNLB from 'fnlb' ;
const fnlb = new FNLB ();
async function startFNLB () {
await fnlb . start ({
apiToken: 'your-api-token' ,
numberOfShards: 1 ,
botsPerShard: 5 ,
categories: [ 'your-category-id' ]
});
}
async function restartFNLB () {
console . log ( 'π Restarting FNLB...' );
await fnlb . stop ();
await startFNLB ();
}
await startFNLB ();
// β±οΈ Restart every hour (3600000 ms)
setInterval ( restartFNLB , 3_600_000 );
π Useful Links
Need help, support, or just want to chat with other developers?
Come hang out with us on Discord! π
Join Discord Get help, support, or chat with other developers