Workers - Ganyu-Studios/stelle-music GitHub Wiki

  • Workers... something that what I think of as: pain in the ass.

Note

Stelle is able to run with some modifications (and limitations) using WorkerClient.
But I do not promise it has full functionality given the way I made it.

By default, Stelle uses the Gateway Client type to create the bot client.
This client type does the sharding automatically depending on the servers, but I guess that won't be enough for some people.

Important

If you are trying to change the client type, PLEASE make sure you follow the Guide section.

📜 Usage

  1. Go to the Stelle.ts class and change Client to WorkerClient.
  2. Go to /src/ and create a file named (for example) manager.ts.
Click to show.
//
// IMPORTANT:
// THIS IS A EXAMPLE MANAGER, YOU NEED TO ADAPT IT TO WHATEVER YOUR NEEDS ARE!!!
// YOU CAN COPY AND PASTE IT, BUT THERE IS NO GUARANTEE THAT IT WILL WORK PROPERLY
//

import { WorkerManager } from "seyfert";

/**
 * The worker manager to be used.
 * @type {WorkerManager}
 */
const manager: WorkerManager = new WorkerManager({
    mode: "threads",
    path: "./dist/index.js"
});

// something fun now.
(async (): Promise<void> => await manager.start())();
  1. The method presence will throw a type error because it no longer exists in the options.
Click to show.

Just remove the method and you should be fine.
image You can move it into the WorkerManager options.

  1. Some gateway properties that were used previously must be replaced.
Click to show.

Replace mentions of client.gateway with this:

image

Replace shardId with... whatever is your shard.

  1. Locate the file presence.ts and delete it.
Click to show.

At the moment, I didn't find a way to make it work (that's your work, friend).
The desire to execute workers has limitations.
image
So... ¯\_(ツ)_/¯

  1. Environment variables
Click to show.

Only follow this if you are getting one of this errors:

image
image

Cut this line:
image
And paste it into the seyfert.config.mjs at the top of the file, like this:
image

  1. The start script (optional)
Click to show.

Add the "worker" script to your scripts object.

{
    "scripts": {
        "worker": "node ./dist/index.js" 
    }
}

📜 The end?

And I think that should be all there is to it.

⚠️ **GitHub.com Fallback** ⚠️