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#L15
3 Replies
d.js toolkit
d.js toolkit10mo ago
- 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 OP
Kinect3000
Kinect300010mo ago
Guild 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
Sam
Sam10mo ago
Thank you!
Want results from more Discord servers?
Add your server