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.
- Go to the
Stelle.ts
class and changeClient
toWorkerClient
. - 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())();
- 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.
You can move it into the
WorkerManager
options.
- Some
gateway
properties that were used previously must be replaced.
Click to show.
Replace mentions of
client.gateway
with this:
Replace
shardId
with... whatever is your shard.
- 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.
So...¯\_(ツ)_/¯
- Environment variables
Click to show.
Cut this line:
And paste it into theseyfert.config.mjs
at the top of the file, like this:
- The start script (optional)
Click to show.
Add the "worker" script to your scripts object.
{
"scripts": {
"worker": "node ./dist/index.js"
}
}
And I think that should be all there is to it.