why does this not work in sapphire

index.js
const { util } = require("./utils");
const { container } = require("@sapphire/framework");

container.util = util;
const { util } = require("./utils");
const { container } = require("@sapphire/framework");

container.util = util;
basically I want to access ./utils using this.container.util
Solution:
That would be:
const util = require("./utils");
const util = require("./utils");
...
Jump to solution
14 Replies
Spinel
Spinel•2y ago
When asking for help, make sure to provide as much detail as possible. What have you tried so far? Do you have stacktraces that you can show us? What are you trying to achieve? Try to answer these questions and others, so we do not have to ask for them afterwards.
❯ For a good guide on how to ask questions, see the instructions that StackOverflow gives. You should try to always follow these guidelines. ❯ For an excellent video that shows how not to ask technical questions is this, watch this YouTube video by LiveOverflow. ❯ Asking technical questions (Clarkson) ❯ How to ask questions the smart way (Raymond)
Lioness100
Lioness100•2y ago
Specifically, what problem are you running into? @-Carlosđź‘‘
-Carlosđź‘‘
-Carlos👑OP•2y ago
it returns undefined
Lioness100
Lioness100•2y ago
what, where, when
-Carlosđź‘‘
-Carlos👑OP•2y ago
evaled it using my eval cmd
Lioness100
Lioness100•2y ago
Can you show your full index.js?
-Carlosđź‘‘
-Carlos👑OP•2y ago
.
Lioness100
Lioness100•2y ago
Can you show utils.js please? 🙂
-Carlosđź‘‘
-Carlos👑OP•2y ago
it's pretty long but here's a small part of it .
Lioness100
Lioness100•2y ago
It looks like you're not exporting anything called util Did you mean to use a default import?
Solution
Lioness100
Lioness100•2y ago
That would be:
const util = require("./utils");
const util = require("./utils");
Lioness100
Lioness100•2y ago
(removal of curly brackets)
-Carlosđź‘‘
-Carlos👑OP•2y ago
didn't notice that, thanks
Lioness100
Lioness100•2y ago
Np 🙂
Want results from more Discord servers?
Add your server