Access extended sapphire client

Following usecase: I extended the sapphire client in order to create custom collections etc. Is there any way I can access the extended client through the container?
Solution:
container.client, and you need to add module augmentation to add the properties to the Client class from discord.js ```ts declare module 'discord.js' { interface Client { myCustomProperty: any...
Jump to solution
9 Replies
Solution
Favna
Favna•2y ago
container.client, and you need to add module augmentation to add the properties to the Client class from discord.js
declare module 'discord.js' {
interface Client {
myCustomProperty: any
}
}
declare module 'discord.js' {
interface Client {
myCustomProperty: any
}
}
Favna
Favna•2y ago
anyway why would you add them to the client specifically when you can also just add them to the container directly. Save yourself the trouble of doing container.client.custom and just do container.custom
kyra
kyra•2y ago
By the way, you're more encouraged to extend container rather than SapphireClient 👀
Favna
Favna•2y ago
It's also far easier because you can just:
import { container } from '@sapphire/framework';
import { CustomColelction } from 'whatever';

container.custom = new CustomCollection();

declare module '@sapphire/framework' {
export interface Container {
custom: CustomCollection;
}
}
import { container } from '@sapphire/framework';
import { CustomColelction } from 'whatever';

container.custom = new CustomCollection();

declare module '@sapphire/framework' {
export interface Container {
custom: CustomCollection;
}
}
ShowCast
ShowCastOP•2y ago
Thanks for the help <:PES_Ok:493353112501747712>
.
.•2y ago
i tried this and it's giving me an error
.
.•2y ago
KaydaFox
KaydaFox•2y ago
for typescript to recognise it for me, i have to do it like this
declare module '@sapphire/pieces' {
interface Container {
config: KaydaConfig
db: PrismaClient;
}
}
declare module '@sapphire/pieces' {
interface Container {
config: KaydaConfig
db: PrismaClient;
}
}
seems to be done that way in iriss too so @Upsided i think you should maybe try that instead?
.
.•2y ago
thanks mayne it worked
Want results from more Discord servers?
Add your server