Guilds
Guilds vs. servers
I often see people confusing guilds with servers, so i thought i'd clear things up real quick.
A "guild" is the technical term for what's known as a "server" in the UI. What i call "servers" throughout the docs are actual servers that u can connect to, such as the media servers used to speak and livestream in voice channels.
Different guild objects
Discord will often only provide parts of a guild object. Anarchy therefore has various guild classes that vary in information to fit what's given to us. Here's a list of all the different classes:
MinimalGuild: The class with the least possible information. The only property is .Id, but that's enough to call most of the endpoints.
PartialGuild: Returned only by the .GetGuilds() method. Only unique feature of this class is that all your permissions are present.
DiscordGuild: Closest to you'll get to a full guild through the REST API.
UnavailableGuild: Only used in the OnLeftGuild event. The .Removed member can be used to check whether the user was actually removed, or if the server is having an outage.
SocketGuild: These are only provided through the gateway. These are provided to you through events, as well as .GetCachedGuilds() and .GetCachedGuild() if you have caching enabled (duh).
Permissions
Permissions are a crucial part of Discord guilds. They're what decides what a member can and cannot do. Behind the scenes, permissions are a number comprised of multiple values OR'd. The DiscordPermission maps the values, so just doing the bitwise operations yourself works, although there are some extension methods available to make your life easier.
Manual bitwise operations
Using the helper methods
Multiple permissions can, in multiple examples, be checked for / added / removed in a single call.
Permission overwrites
Discord allows overwriting of members/roles in the scope of a singular (or more because of synchronized permissions) channel. A GuildChannel's permission overwrites are located at .PermissionOverwrites.
GuildMember.GetPermissions() has an overload accepting an IEnumerable<DiscordPermissionOverwrite>
. Example:
In this example, the user is allowed to send messages according to the roles, but an overwrite, well... overwrites that.
DiscordPermissionDiscordPermissionOverwriteChannelsMembers
Discord have recently removed the ability for user accounts to request members the same way bot accounts do. Anarchy has methods for both, so make sure to use the right one!
Bots can use the .GetGuildMembers() method, whilst users can only use .GetGuildChannelMembers(). The method for users works like Discord's Member List, meaning that it only gets members that have access to it. Both methods return an IReadOnlyList<GuildMember>
and are available for gateway clients only.
Webhooks
There are 2 types of webhooks: incoming webhooks, which send messages and are authenticated using a token, and channel followers that crosspost messages from news channels. Anarchy has extensive functionality for both of them.
Requesting a webhook
Incoming webhooks
Incoming webhooks are the classic webhooks we all know and love. They simply send messages as you command.
Sending messages
Channel followers
Channel followers, or crossposters, are webhooks that send messages from a news channel to the specified channel, hence the term "crossposting".
In the following examples, the 'sourceChannel' will be a TextChannel with a .Type of News.
Creating crossposters
Crossposting/publishing messages
If you have permissions to manage the news channel, you can "publish" messages, which will forward them to all the channel followers for the channel.
Last updated
Was this helpful?