Replies: 2 comments 2 replies
-
It's probably worth mentioning as well, I have also tried:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Seems like you are using v5. If so, please load the app when running the command using the following option. https://v5-docs.adonisjs.com/guides/ace-commandline#booting-the-app-within-the-command public static settings = {
loadApp: true
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I am reaching out to get some support with the IoC and how it works with commands.
I have a singleton, which is registered with the container. I can confirm this by adding some logs in there and can see them in the terminal once it has been started.
The idea is, I have a singleton which is for all Discord interaction from my API, to avoid having to do multiple login requests etc and when resolving this from the IoC it'll be the instance which has the clients, guilds etc and I can interact with them from there accordingly.
However, when trying to use this within a command, which is used to sync roles it just doesn't seem to be working.
I am binding it like so:
providers/discord_provider.ts
Then inside of the command, I am just doing something as simple as the following:
I have tried this the manual way but have also tried to do the @Inject decorator as well, as per the docs but haven't managed to have any successful attempt.
The error which I get when doing it manually is:
If I do it using the decorator I get the following:
Apologies if this is quite a nooby question, I've tried Stack Overflow and also looking at the documentation a lot but can't seem to come to any resolution, so any help is much appreciated! 🙏
Beta Was this translation helpful? Give feedback.
All reactions