New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

kurasuta

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kurasuta

A Custom discord.js Sharding Library inspired by eris-sharder.

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
decreased by-86.42%
Maintainers
1
Weekly downloads
 
Created
Source

Kurasuta

About

kurasuta is a powerful sharding manager for the discord.js library. It uses Node.js's cluster module to spread shards evenly among all cores.

Installation and Usage

To download kurasuta, run npm install kurasuta If you use Yarn, run yarn add kurasuta

To use kurasuta, you can take a look at example

ShardingManager

NameDescription
tokenYour bot token. It will be used to query the Session endpoint and calculate how many shards to spawn.
pathpath to a file that exports a class extending Cluster. The class must containt a method called "launch".
options.clientOptionsA object of client options you want to pass to the d.js client constructor.
options.clusterCountThe number of how many clusters you want. Defaults to the amount of cores
options.shardCountThe number of how many shards you want. Defaults to the amount that the gateway reccommends, taking into account options.guildsPerShard
options.developmentBoolean to enable development mode.
options.clientClass extending the d.js client you want to use for your clusters (usefull for Frameworks like Commando, Klasa or Akairo). Default to d.js Client
options.guildsPerShardNumber to calculate how many guilds per shard. Defaults to 1000. Ignored if you set shardCount.
options.respawnBoolean indicating if exited Clusters should always get restarted. Default to true
options.ipcSocketPath to Socket that should be used for IPC connections. Default to //./pipe/tmp/echo.sock on Windows and '/tmp/echo.sock' on Linux

Cluster

In every cluster when your code is loaded, you get access to this.client and this.id. this.client is an instance of the Client you provided with nearly no modifications beside the shard property, d.js build-in ShardClientUtil is replaced by kurasuta's one.

ShardClientUtil

MethodExampleDescriptionReturns
broadcastEvalclient.shard.broadcastEval(script);Eval's a script on all Clusters in context of the ClientPromise<any[]>
masterEvalclient.shard.masterEval(script);Eval a script on the master process in context of the ShardingManagerPromise
fetchClientValuesclient.shard.fetchClientValues(prop);Fetch a Client value on all ClustersPromise<any[]>
restartAllclient.shard.restartAll()Sends a message to the master process to kill & restart all ClustersPromise
restartclient.shard.restart(cluserID)restart a specific cluster by idPromise
sendclient.shard.send(data, options)send a message to the master processPromise

Example

Directory Tree

In this example our setup look like this:

Project/
├── node-modules/
│   ├── kurasuta
|
├── src/
│   ├── main.js
|   ├── index.js

Example of main.js

const { Cluster } = require('kurasuta');

module.exports = class extends Cluster {
	launch() {
		
	}
}

Example of index.js

const { ShardingManager } = require('kurasuta');
const { join } = require('path');
const sharder = new ShardingManager('YOUR_TOKEN', join(__dirname, 'main'), {
	// your options here
});

FAQs

Package last updated on 04 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc