mongoose listener not working

im trying to setup a mongoose listener for the 'open' event however saphire doesnt seem to catch it my best guess is i didnt specify the right emitter as my other listeners work here is a screenshot
S
s4g394d ago
equivalent code would be connection.on("open", () => { container.client.logger.info("Succesfully Connected To DB Instance"); }); tested and it works
F
Favna394d ago
i'm assuming connection is something that is available as emitter through dependency injection when using mongoose? when is it being initialised? Or rather, can you try setting a breakpoint / adding console.log to node_modules/@sapphire/framework/dist/lib/structures/Listener.js between line 14 and 15? To check whether this.emitter is null or not. because if it's null when the listener is loaded because the connetion is established too late then the listener doesn't get enabled
S
s4g393d ago
console.log(this.emitter)
S
s4g393d ago
F
Favna393d ago
okay so it's not null I'm honestly not sure then I don't use Mongoose (or MongoDB for that matter)
F
Favna393d ago
I know it's not really a solution per-se but you could consider switching to https://www.prisma.io which is the ORM that most of us here use
Prisma
Prisma | Next-generation ORM for Node.js & TypeScript
Prisma is a next-generation Node.js and TypeScript ORM for PostgreSQL, MySQL, SQL Server, SQLite, MongoDB, and CockroachDB. It provides type-safety, automated migrations, and an intuitive data model.
S
s4g393d ago
i think ill switch to prisma thx for the help do you have any examples for sapphire with prisma?
F
Favna393d ago
@Gemboard uses it, it's open source on our GH org
Want results from more Discord servers?
Add your server
More Posts
TypeError: channel.isTextBased is not a functionI have a problem with Interactions: Since yesterday evening every button interaction results in an eCan not resolve dependency sapphireHello, after todays NODE JS update, im having an issue with sapphire dependency, would you be able tUserError listener not catching all errorsI am running an imported function in my command, and calling UserError in this file and when I do, iNested message component collectorsHow should I be handling nested message component collectors? What the best way to do itHow to get message args ?Like i have command `+mark 123`, how i can get the `123`API Placeholder in RouteI didn't found it in the docs. Is there any way to get a placeholder into a route like in express wiTypeError piace.aliases is not iterableGood afternoon, I mixed such a strange code as best I could. My task was to add a button to the messI'm getting this error when used my new precondtion.my fileAPIInteractionDataResolvedGuildMember does not have idWhile fetching for member using `interaction.options.getMember('member')` it gives two types - `GuilAPI Client with SSL?Hey guys, currently I am trying to make the switch from an custom express API to the API plugin. IsContext Menu Command and Subcommand cannot be in same extended class?I have a slash command which is an extended `Subcommand` called `give-role` with two subcommands - `UserErrors not being caught by listener - bot is crashingmessageCommandError.mjs ```js import { Events, Listener } from "@sapphire/framework"; import { send Subcommand isn't runningWhen the subcommand is run in Discord, it times out. I've added a log to the beginning of the methodHow to properly handle UserErrors?I'm using the official sapphire template and want to throw a UserError inside a context menu commandCan I set different requiredUserPermissions for each subcommand?Just wondering if this is possible, and how. ThanksHandling BulkOverwrite Registry ErrorsWhen I encounter this error ``` [ERROR] ApplicationCommandRegistries(BulkOverwrite) Failed to overwrEvents for VoiceHow can I do something like the following but for voice? ``` import { Listener } from '@sapphire/frHow do I use autocompleteRun on subcommands?^ As the title says. I can't seem to figure out how subcommands can have autocompleteRun implementedMessage editing fails even though message can be fetchedWhenever I want to edit an ephemeral message I get the following error: ```js [ERROR] Encountered erProblem with ephemeral messagesI currently have a command which sends a button, problem is, once the button is pressed, I can't rem