Channels

Channel classes

Anarchy has multiple channel classes to match the data for the different types of Discord channels (DM, Group, Text, etc.).

  • PrivateChannel: For any private channel; DM or Group.

  • DiscordGroup: Only for groups.

  • GuildChannel: For all channels within a guild.

  • TextChannel: For guild text channels. News and Store channels also fall under this.

  • VoiceChannel: For guild voice channels.

Aside from these, the minimal objects MinimalChannel and MinimalTextChannel also exist.

pageDocumentation structurepageGuilds

Text channels

Messages can be sent through Text, News, Store, DM and Group channels.

Sending messages

Consider the following .

channel.SendMessage("Hi!", false, new EmbedMaker() { Title = "hello" });
channel.SendMessage("hey");
channel.SendMessage(new EmbedMaker() { Title = "sup" });

All of the 3 .SendMessage() calls above are valid, because there's either supplied a message or an embed.

Editing messages

DiscordMessage msg = channel.SendMessage(new EmbedMaker() { Title = "Anarchy" });
msg.AddReaction("✅");

// Discord currently only allows SuppressEmbeds
msg.Edit(new MessageEditProperties() { Flags = MessageFlags.SuppressEmbeds });

This will supress the embed in your message, making it look like the reaction is the message itself ;).

IMessageChannel

Unfortunately, the channel types that allow messages don't exactly follow Anarchy's channel type hierarchy. Therefore, the IMessageChannel interface exists. This means that you could, for example, create a method that accepts an IMessageChannel to include both guild and private text channels. The MinimalTextChannel (which is used instead of MinimalChannel whenever the type is known to allow messages) class also inherits this interface.

pageIMessageChannelpageMinimalTextChannelpageDiscordMessagepageGuilds

Last updated