Indomitable
A lightweight (the actual ship is heavy though), performat & powerful sharder for Discord.JS. Indomitable uses cluster module to evenly spread her weight (load) across your cores
The ShipGirl Project; ⓒ Azur Lane
- Supports Discord.JS
v13
anddiscord.js@dev
Installation
- Stable
npm install indomitable
- Dev
npm install https://github.com/Deivu/Indomitable.git#master
Documentation
Example Usage
Basic usage
const { Indomitable } = require('indomitable');
const { Client } = require('discord.js');
const token = 'your_token';
const manager = new Indomitable({ client: Client, token })
.on('error', console.error);
manager.spawn();
Basic usage with more Indomitable Options
const { Indomitable } = require('indomitable');
const { Client } = require('discord.js');
const token = 'your_token';
const options = {
// Processes to run
clusterCount: 2,
// Websocket shards to run
shardCount: 8,
// Discord.JS options
clientOptions: {
intents: [1 << 0] // Bitwise for GUILD intent only
},
// Auto restart processes that have been killed
autoRestart: true, // This defaults to false by default unless you specify it
// Your Discord.JS client
client: Client,
// Your bot token
token
}
const manager = new Indomitable(client)
.on('error', console.error);
manager.spawn();
Broadcasteval as one way to get data across shards
// Saya's note:
// Not recommended as every broadcastEval uses eval() internally
// Consider learning the ipc system of this library in future to get data across your clusters
client.shard
.broadcastEval(client => client.guilds.cache.size)
.then(console.log);
Notes
-
You don't need to call
client.login('token');
yourself, Indomitable will call it for you. -
Extended clients that extend from discord.js client will work, as long as you use
client.login('token');
to get your bot running -
For fastest performance possible, install the optional dependency MessagePack
npm i --save msgpackr
-
Your Discord.JS Client ShardClientUtil is replaced with Indomitable's ShardClientUtil. Refer to our docs for documentation
🔗 https://deivu.github.io/Indomitable/classes/client_ShardClientUtil.ShardClientUtil.html
Indomitable Options
Option | Type | Description | Required | Default |
---|---|---|---|---|
clusterCount | number or 'auto' | How many clusters we should spawn | No | 'auto' |
shardCount | number or 'auto' | How many websocket shards we should make | No | 'auto' |
clientOptions | Object | Discord.JS Client Options | No | {} |
ipcOptions | Object{primary?: {}, worker?: {}} | Options for net-ipc | No | {} |
nodeArgs | string[] | Node arguments to pass to a cluster | No | [] |
ipcTimeout | number | Timeout before we fail a request | No | 60000 |
spawnTimeout | number | Timeout before we fail a cluster spawn | No | 60000 (multiplied by clusterShardCount internally) |
spawnDelay | number | Time to wait before spawning a new cluster | No | 5000 |
autoRestart | boolean | If you want to auto restart the shards that have been killed unintentionally | No | false |
client | Client | Your Discord.JS non modified OR modified client | Yes | None |
token | strubg | The token of your bot | Yes | None |
❤
by
Made with @Sāya#0113 (https://github.com/Deivu/)