kyeede
Circular Dependency
Heyo :D,
So I have started getting into somewhat bigger projects again and needed to use Dependency Injections to loose coupling and overall tightness between classes. Since 2 of my classes (and likely in the future, more class depend on each other), it's a good approach to create abstractions to expose only a fraction of the class that other classes need to access. This way, I am not exposing it concretely. However, for some reason, I am running into a circular dependency exception which I don't seem to... really understand? I get where the issue is but I can't figure out a more plausible approach. I would appreciate some feedback on what potentially can be done.
To give the issue.. ILoggingManager depends on IYukkaifyEnvironment, which in turn depends on ILoggingManager..
58 replies
Parse embed from Json into EmbedBuilderUtils
Hello! :D
For my own convenience and to not clog up my entire class file with endless amounts of lines. I created a json file that holds numerous of preset embeds that I wanna use. However, I'm stuck on an issue and I certainly cannot seem to figure out the issue whatsoever.
i simply want to parse the embed into a utility that is named EmbedBuilderUtils which is provided by Discord.NET. It basically goes like this
This should technically speaking work? unless there is another way to parse first_embed's object entirely. I'm quite lost on this. Any help is appreciated!
38 replies
Access values from a record without explicitly calling .Value
To keep it quite short, I have a record as followed
Now when I wanna use it, I simply do something like
The annoying part is, upon deserializing it and wanting to access it, I need to do
TestString.Value
. Is there a way to change the code snippet to simply not use .Value
at all? Quite new to records.16 replies
❔ Creating a json array and reading a specific property
Hello!
So i have a json file as followed
I want to read let's say everything from
embed1
as if it was its own file. The thing to consider is that it has to be a string since the parameter is a string since im reading it like this
I am getting this error and idk what to do... Unexpected character encountered while parsing value: A. Path '', line 0, position 0.
.35 replies
Foreach loop inside List<T> class
Okay so I'm actually quite confused on this. I have a collection of roles that I'd like to store inside a JSON file. My goal is to obtain every role's information within a guild by first obtaining the RoleCollection and then initiating a foreach loop to add it into a class list so later on I can serialize that information into a JSON file.
Is something like this possible? I'd like to do this way so upon the system detecting a new guild, it stores basic guild information and each role (to set up a permission-like system for commands)
34 replies
❔ Implement New Class to JSON with Default Values
Hello,
I have a class as followed:
Which returns:
Now, let's say I add a new class to
GuildModulesConfiguration
which would looks like this:
Whenever I try to deserialize and serialize the JSON file, it adds the new class as null without any values.
What I want to achieve is this:
Any ideas what I could possibly do? 40 replies
Update JSON File with new values without overwriting existing data
Hello,
So I'm currently developing a Discord bot that stores values such as 'settings' for each guild. I already got that part figured out very well but I would like to know how I should handle additions / removes.
I have a class as followed:
As an example, currently, the json file doesn't have the
public bool EnableModeratorNotifications
included but it is a new feature I would like to add. If I add that to my class, how would I serialize it into the json file with a default value like true/false without overwriting the existing values there?76 replies