How can I delay the loading of pieces?
Is there a way I can control when the pieces are loaded instead of having them loaded automatically on
<SapphireClient>.login
? I'd like to login to the client, then wait for the resolving of an async function, and then load the pieces in.Solution:Jump to solution
mark them as internal by prefixing the file name with
_
or putting them in a directory that doesn't get automatically detected by Sapphire (i.e. a folder other than arguments
, commands
, etc) then use
```ts
import { container } from '@sapphire/framework';
container.stores.loadPiece({
name: 'name of the piece here',...7 Replies
Solution
mark them as internal by prefixing the file name with
_
or putting them in a directory that doesn't get automatically detected by Sapphire (i.e. a folder other than arguments
, commands
, etc) then use
This is also how built in pieces are loaded so no fs operations are required:
- https://github.com/sapphiredev/framework/blob/9b42bcd2041bd440d8d8d3da62bc362d588e5a56/src/arguments/CoreBoolean.ts#L24-L28
- https://github.com/sapphiredev/framework/blob/main/src/arguments/_load.ts
- https://github.com/sapphiredev/framework/blob/9b42bcd2041bd440d8d8d3da62bc362d588e5a56/src/lib/SapphireClient.ts#L22Awesome this is exactly what I'm looking for
or if you want to do this for all pieces set
baseUserDirectory
to null
where is the guide pageSapphire Framework
Registering and loading virtual pieces | Sapphire
Virtual pieces differ from normal pieces in that they are not loaded from the file system. Instead, they are registered
By the way since I have you here... This is related to something I'm trying to do for emojis after setting up your package
@favware/discord-application-emojis-manager
. I followed up on the message from your private server "Favware", not sure if you've seen it
https://discord.com/channels/512303595966824458/512635182797291520/1297344404935151667I did see it, I didnt reply to it yet
I want to load the emojis based on their names, and since I'm then using these custom emojis on some of my pieces, I want to make sure they're loaded before I start receiving events/commands
Think I should be able to do it with this but wanted to sanity check I'm not stupidly overthinking this and there's a much easier way to do it 😅