How are circular Dependancies avoided in Djs
in djs, guilds needs to have roles:
<guild>.roles
and a role needs to have a guild: <role>.guild
how does this not result in a circular dependency of the guild
and role
classes in https://github.com/discordjs/discord.js/blob/main/packages/discord.js/src/structures/Role.js#L15
and
https://github.com/discordjs/discord.js/blob/main/packages/discord.js/src/structures/Guild.js#L153 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by OPGuild is passed into the constructor of Role (constructor dependency injection)
Role doesn’t create the Guild instance, so it doesn’t need to import it
Thank you!