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...
Solution
F
Favna416d 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
}
}
F
Favna416d 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
K
kyra416d ago
By the way, you're more encouraged to extend container rather than SapphireClient 👀
F
Favna416d 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;
}
}
S
ShowCast414d ago
Thanks for the help <:PES_Ok:493353112501747712>
~406d ago
i tried this and it's giving me an error
~406d ago
K
KaydaFox406d 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?
~404d ago
thanks mayne it worked
Want results from more Discord servers?
Add your server
More Posts
Version mismatch between Sapphire and dapi-typesHi, I was updating my dependencies when I encountered Discord.js' dapi-types error. I copy/pasted thWhats the syntax to require Permission X AND Y OR Z when using requiredUserPermissionswhen using `requiredUserPermissions`. Its an array so Im not sureGetting modalSubmit error over the weekendDid discord change something???How to use windows env variables using skyra env utilitiesi am trying to use CD for hosting and i have env variables set on windows, how do i access them withPattern for fetching all registered slash commandsI have some slash commands and some with subcommands and and want to introduce a `/help` slash comminteraction.showModal not workinginteraction.showModal doesnt work, I dont know why. Code: ``` this.container.logger.debug("Start EdPrecondition with Slash CommandHow to report precondition failure w/ clash command? If I use `this.error({ message: 'error' });` iHow to use skyra env utilities with the cli generated project?I want to use env variables to store my mongo uri, but due to skyra utilities being their i cant useHow to get the current channel a slash command was used inI took a look at the following post https://discord.com/channels/737141877803057244/1061609301556346Preventing Commands in DMsHow do you prevent commands from being used in DMs? Message commands.autoModerationActionExecution EventDoes Sapphire not emit the Discord.js `autoModerationActionExecution` event? The following code doeHelp canceling a commandHere the code I have for a simple reminder command.https://pastebin.com/crRSdjEn. It works but id liHow to check if the bot has Permission X inside of the server? For example VIEW_AUDIT_LOGIn a listenerWhat parameter do I pass to the run method in my GuildCreate listener?Problem with this.container.stores.get().get();Code:InteractionCreate fileCan I easily create a listener for `interactionCreate`? I need it for some UI Abilities, and I am noHow to Create Threads?I dont get how to create threads programmatically. Please helpCommand infodoes sapphire have a built in command info funtions so we can get for example the aliases of a commaargs.pick("member")using `args.pick("member")`, is it intended to get the member even if you just provide 1 letter of twhy does this not work in sapphireindex.js ```js const { util } = require("./utils"); const { container } = require("@sapphire/framewo