PHP Classes

File: examples/06-sharding.md

Recommend this page to a friend!
  Packages of Max   Fenrir   examples/06-sharding.md   Download  
File: examples/06-sharding.md
Role: Auxiliary data
Content type: text/markdown
Description: Auxiliary data
Class: Fenrir
Use Discord services using the Web services API
Author: By
Last change:
Date: 4 months ago
Size: 860 bytes
 

 

Contents

Class file image Download

Filtered event listener

Bigger bots will require to use sharding. With sharding, you can split up the amount of Guilds a process handles, making it possible to scale your bot horizontally.

For this, you can use Ragnarok\Fenrir\Gateway\Shard.

The constructor takes 2 parameters,

  1. `$shardId`, the shard the current process will control
  2. `$numShards`, the total amount of shards

You can then pass this Shard instance along to the gateway connection. $discord->gateway->shard($shard).

Note that this method takes an instance of Ragnarok\Fenrir\Gateway\ShardInterface. If you need additional logic in order to prepare the shard array for the identify payload, you can create your own implementation for it.

Refer to the Discord developer documentation for more info on sharding.