{"id":25488388,"url":"https://github.com/nobu-sh/yuasharder","last_synced_at":"2026-04-28T23:34:40.623Z","repository":{"id":39878875,"uuid":"347224785","full_name":"nobu-sh/yuasharder","owner":"nobu-sh","description":"Sharder and Clusterer for Yua utilizing Discord Eris Library","archived":false,"fork":false,"pushed_at":"2022-05-23T19:21:16.000Z","size":128,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-12T02:22:30.589Z","etag":null,"topics":["bot","cluster","clustering","clusters","discord","eris","sharder","sharding","shards"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nobu-sh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-12T23:30:24.000Z","updated_at":"2022-05-23T19:21:20.000Z","dependencies_parsed_at":"2022-09-12T14:25:54.870Z","dependency_job_id":null,"html_url":"https://github.com/nobu-sh/yuasharder","commit_stats":null,"previous_names":["nobuwu/yuasharder"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nobu-sh%2Fyuasharder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nobu-sh%2Fyuasharder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nobu-sh%2Fyuasharder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nobu-sh%2Fyuasharder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nobu-sh","download_url":"https://codeload.github.com/nobu-sh/yuasharder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239550314,"owners_count":19657540,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","cluster","clustering","clusters","discord","eris","sharder","sharding","shards"],"created_at":"2025-02-18T20:51:46.081Z","updated_at":"2025-11-08T06:30:35.434Z","avatar_url":"https://github.com/nobu-sh.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YuaSharder\n\nYuaSharder is a clustering and sharding library for [Discord Eris](https://github.com/abalabahaha/eris) written in typescript with typings.\n\nIt was written explicitly for [Yua Bot](https://discord.gg/yua) but I decided to open source it as there are not too many good working libraries for sharding and clustering.\n\n## Installation\n\nNode Version: ᵗᵇʰ ᶦᵈᵏ ˡᵐᵃᵒ\n\n```npm\nnpm install yuasharder\n```\n\n## Simple Usage\n\n`index.js`\n```js\nconst { Manager } = require('yuasharder')\n\nconst manager = new Manager(\"Cool-Discord-Token\", \"/bot.js\", {})\n\nmanager.launch()\n```\n`bot.js`\n```js\nconst { Base } = require('yuasharder')\n\nclass Bot extends Base {\n  constructor(props) {\n    super(props)\n  }\n  init() {\n    console.log(\"Logged in as\", this.client.user.username)\n  }\n}\n\nmodule.exports = Bot\n\n```\n`package.json`\n```json\n{\n  \"name\": \"my-bot\",\n  \"version\": \"1.0.0\",\n  \"description\": \"My cool bot\",\n  \"main\": \"index.js\",\n  \"author\": \"You silly\",\n  \"license\": \"ISC\",\n  \"dependencies\": {\n    \"yuasharder\": \"^1.0.0\"\n  }\n}\n```\n\nStart with `node .`\n\n## More Info/Examples\n\n### `yuasharder.Manager(token, file, options)`\n|parameter|Type|Default|Description|\n|:---  |:---|:---   |:--- |\n|`token`|`string`|`undefined`|Bot API Token|\n|`file`|`string`|`undefined`|File path relative to root|\n|`options`|`ClusterManagerOptions`|`null`|Options passed to manager|\n|`options.totalShards`|`number`|`null`|Specifies amount of shards, checks gateway if null|\n|`options.totalClusters`|`number`|`node:os.numCPUs()`|Amount fo clusters to spread shards across|\n|`options.firstShardID`|`number`|`0`|Shard that yuasharder should start on|\n|`options.lastShardID`|`number`|`firstShardID - 1`|Shard that yuasharder should end on|\n|`options.clusterTimeout`|`number`|`5`|Timeout between launching each cluster (seconds)|\n|`options.statsInterval`|`number`|`60`|Interval between each stats event emitted (seconds)|\n|`options.guildsPerShard`|`number`|`1300`|Amount of guilds per shard (`totalShards` must be `null`)|\n|`options.clientOptions`|`Eris.ClientOptions`|`{}`|Eris client options to pass to bot|\n\n\n### Functions\n`Manager` *extends* `node:events.EventEmitter`\n\n\n#### `launch()` `void`\n|Parameters|Type|Description|\n|:---      |:---|:---       |\n\n\u003e *Launch yuasharder*\n\n\n#### `broadcast(start, message)` `void`\n|Parameters|Type|Description|\n|:---      |:---|:---       |\n|`start`|`number`|Cluster to start boradcasting from|\n|`message`|`IPCEvents`|Message to broadcast|\n\n\u003e *Broadcast message to all clusters*\n\n#### `sendTo(cluster, message)` `void`\n|Parameters|Type|Description|\n|:---      |:---|:---       |\n|`cluster`|`number`|Cluster to send message to|\n|`message`|`IPCEvents`|Message to broadcast|\n \n\u003e *Send message to specific cluster*\n\n### Events\n\n|Event|Callback |Emits on?| \n|:--- |  :---  |:---     |\n|`info`|`string`|General info|\n|`error`|`any`|On  error|\n|`stats`|`MasterStats`|Stats interval|\n|`clusterInfo`|`ClusterMessages`|General cluster info|\n|`clusterWarn`|`ClusterMessages`|Something semi dangerous|\n|`clusterError`|`ClusterMessages`|On cluster error|\n|`shardConnect`|`ShardMessages`|When shard connects|\n|`shardDisconnect`|`ShardMessages`|When shard disconnects|\n|`shardReady`|`ShardMessages`|When a shard becomes ready|\n|`shardResume`|`ShardMessages`|When shard resumes|\n|`shardWarn`|`ShardMessages`|Something semi dangerous occurs|\n|`shardError`|`ShardMessages`|When shard runs into error|\n\n#### Example Usage\n\n```js\nconst { Manager } = require('yuasharder')\n\nconst manager = new Manager(\"Cool-Discord-Token\", \"/bot.js\", {\n  totalShards: null, // Will Check Gateway For Recommended Shards\n  totalClusters: null, // Will Use Number Of Cpus\n  firstShardID: null, // Will Use Default\n  lastShardID: null, // Will Use Default\n  statsInterval: 30, // Every 30 seconds\n  guildsPerShard: 1000, // 1000 Guilds Per Shard\n  clientOptions: {\n    allowedMentions: {\n      everyone: false,\n    },\n  },\n})\n\nmanager.on('stats', (stats) =\u003e {\n  console.log(stats)\n})\n\nmanager.launch()\n```\n\n***\n\n### `yuasharder.Base(props)`\n*Base should not be constructed as it will not do anything, it should always be extended then exported*\n\n|parameter|Type|Description|\n|:---     |:---|:---       |\n|`props`|`BaseClassProps`|props given to contructor by yuasharder|\n|`props.client`|`Eris.Client`|Clusters eris client instance|\n|`options.ipc`|`IPCInterface`|Clusters IPC instance|\n|`options.clusterID`|`number`|Cluster instance is located on|\n\n### Props\n\n#### `.client` `Eris.Client`\n\u003e Eris client instance\n\n#### `.ipc` `IPCInterface`\n\u003e IPC for cluster instance\n\n#### `.clusterID` `number`\n\u003e Id of cluster current instance is on\n\n### Functions\n\n#### `init()` `void`\n|Parameters|Type|Description|\n|:---      |:---|:---       |\n\n\u003e *Used to start code*\n\n#### Example Usage\n\n*It looks like this because yuasharder will create an instance of your bot class extending Base then pass the props shown above to it. It will then run init to start your code*\n\n```js\nconst { Base } = require('yuasharder')\n\nclass Bot extends Base {\n  constructor(props) {\n    super(props)\n  }\n  init() {\n    const bot = this.client\n    const ipc = this.ipc\n    const clusterID = this.clusterID\n    console.log(\"Logged in as\", bot.user.username, \"on cluster\", clusterID)\n  }\n}\n\nmodule.exports = Bot\n\n```\n\n___\n\n### `IPC`\n\n### Default Events\n|Event|Callback |Description| \n|:--- |  :---  |:---     |\n|`stats`|`MasterStats`|All stats|\n\n### Functions\n\n#### `register(event, callback)` `void`\n|Parameters|Type|Description|\n|:---      |:---|:---       |\n|`event`|`string`|Events Name|\n|`callback`|`(msg: IPCEvents) =\u003e void`|Callback function|\n\n\u003e *Register event listener for IPC event*\n\n#### `unregister(event)` `void`\n|Parameters|Type|Description|\n|:---      |:---|:---       |\n|`event`|`string`|Events name|\n\n\u003e *Unregister event listener*\n\n#### `broadcast(event, message)` `void`\n|Parameters|Type|Description|\n|:---      |:---|:---       |\n|`event`|`string`|Events name|\n|`message`|`object`|Message to send with event|\n\n\u003e *Broadcast message to all clusters*\n\n#### `sendTo(clusterID, event, message)` `void`\n|Parameters|Type|Description|\n|:---      |:---|:---       |\n|`clusterID`|`number`|Cluster to send to|\n|`event`|`string`|Events name|\n|`message`|`object`|Message to send with event|\n\n\u003e *Send message to specific cluster*\n\n#### Examples\n\n```js\nconst { Base } = require('yuasharder')\n\nclass Bot extends Base {\n  constructor(props) {\n    super(props)\n  }\n  init() {\n\n    this.ipc.register('stats', (stats) =\u003e {\n      console.log(stats)\n    })\n\n  }\n}\n\nmodule.exports = Bot\n\n```\n\n```js\nconst { Base } = require('yuasharder')\n\nclass Bot extends Base {\n  constructor(props) {\n    super(props)\n  }\n  init() {\n\n    this.ipc.register('PING', (clusterID) =\u003e {\n      this.ipc.sendTo(clusterID, \"PONG\", {\n        clusterID: this.clusterID,\n        uptime: this.client.uptime\n      })\n    })\n\n    this.ipc.register('PONG', (msg) =\u003e {\n      console.log(msg.clusterID, \"responded with\", msg.uptime, \"uptime\")\n    })\n\n    this.ipc.broadcast(\"PING\")\n\n  }\n}\n\nmodule.exports = Bot\n\n```\n\n## Random Extra\n*Just some random extra stuff that may or may not be helpful*\n#### Process Event Object\n```js\n{\n  payload: \"event\",\n  msg: {\n    ...\n  }\n}\n```\n#### IPC Event Object\n```js\n{\n  _eventName: \"event\",\n  msg: {\n    ...\n  }\n}\n```\n\n## Issues / Feature Request\nPlease submit an issue in the issues section and I will try to get back asap\n\n## Contributing\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make be sure to **TEST** all functionality before requesting\n\n## License\n[AGPL-3.0](https://choosealicense.com/licenses/agpl-3.0/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnobu-sh%2Fyuasharder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnobu-sh%2Fyuasharder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnobu-sh%2Fyuasharder/lists"}