Does Custom Piece auto-loaded?
I am trying to develop a ReservationTask Piece using SapphireJS to perform a specified task after a certain time. First, I created a ReservationTask by extending the Piece class and then created a ReservationTaskStore to store it.
In this case, I wonder if the ReservationTask Piece is automatically registered with SapphireJS. Also, if I add a custom Piece that inherits from this Piece, will it also be automatically added?
I plan to refer to the following code frequently during development:
https://github.com/skyra-project/skyra/blob/6c74782c3e84ce90641f4163e86c60263148b867/src/lib/schedule/structures/Task.ts
P.S
I am trying to register a task that performs a Reservation Task after a certain time through a Command, and I found that in Skyra, it encourages registration through the ScheduleManager.
In this case, the TaskStore retrieves a specific task based on the taskId, but the actual Task class does not have an id value, so I am curious about how this check is done.
GitHub
skyra/src/lib/schedule/structures/Task.ts at 6c74782c3e84ce90641f41...
A multipurpose Discord Bot designed to carry out most of your server's needs with great performance and stability. - skyra-project/skyra
Solution:Jump to solution
semi auto, you do have to configure the path of the store and add it to the store collection.
3 Replies
Solution
semi auto, you do have to configure the path of the store and add it to the store collection.
Other than the skyra code you can also look at https://github.com/sapphiredev/plugins specifically the API plugin.
GitHub
GitHub - sapphiredev/plugins: Plugins for the Sapphire Framework
Plugins for the Sapphire Framework. Contribute to sapphiredev/plugins development by creating an account on GitHub.
Thank you so much! I'm wondering if it works by specifying the root directory and recursively exploring modules from there to find the Pieces.
However, I also want to understand the principle behind how SapphireJS dynamically locates the Pieces defined within a package at runtime. Would looking into the
sapphirejs/piece
library be the most accurate way to figure this out?