Anarchy
Search…
Library structure

API-bound classes

Many of the classes containing info from the API are "API-bound". Basically, since Discord responds with JSON objects, the properties within these API-bound classes are mirrors of their target JSON objects. Parsed objects may have information added, such as informing it of the parent client. Anarchy works this way because it gives the end developer more control over the library - transparency is key.

Casting

Some objects returned by discord have different types, which have their own unique data, such as the different types of channels. Anarchy therefore has a universal -> specific class system. Basically, methods like .GetChannel() return a DiscordChannel, which is the universal channel class. This can then be casted to a specific class depending on the type.

Minimal objects

Most of the time, only an ID of some object is needed to do things with it, so since some objects only have an ID to one of those objects, "minimal" objects are used. A minimal object is basically just created from the ID, so you can use the managed methods instead of having to call them from the client. It's a convenience concept, basically.

Exposed / managed methods

Most methods that can be called directly from the client are extension methods. These methods let you decide all the parameters; you're in full control, hence the term "exposed methods". Most of these "exposed methods" have a "managed" equivelant, i.e. a method that's part of another object, which lets it decide some of the parameters. For an example, a guild ID must be passed in the exposed .ModifyGuild(), whilst it's done automatically in MinimalGuild.Modify().
Last modified 1yr ago