Discord splits the user's profile and settings in 2, which is even visible from the UI. The profile is basically the user's name, email, etc., whilst settings are things like message scanning, who can add you, and so on.
client.User.ChangeProfile(new UserProfileUpdate(){Username = "kekmeister9000",Avatar = Image.FromFile("avatar.png"),Password = "ihateniggers123" // password must be provided when changing username, email, discriminator or password});
"Discriminator" is the technical term for the 4 digit number after the #.
client.User.ChangeSettings(new UserSettingsProperties(){Theme = DiscordTheme.Light,DeveloperMode = true,Language = DiscordLanguage.Spanish,CustomStatus = new CustomStatus(){Text = "killing jews",EmojiName = "🔥" // remember to pass EmojiId if it's a custom emoji}});
The UserSettingsProperties class isn't complete, although it contains the most common settings.
Badges are calculated through bitwise operations, much like permissions are. Badges however, cannot just be modified like permissions are. Anarchy's DiscordBadge wraps the numerical values used.
Hypesquad badges are, in fact, the only badges that you can just go out of your way modify.
client.User.SetHypesquad(Hypesquad.Brilliance);client.User.Update(); // Hypesquad doesn't update automatically. my bad...​client.User.Badges.HasFlag(DiscordBadge.HypeBrilliance); // returns trueclient.User.Hypesquad == Hypesquad.Balance // returns false
The Hypesquad badges also exist within DiscordBadge; it's mostly for convenience.
Presences are users' statuses and activities. They're only available for Gateway clients.
Discord has different types of activities, all with their own special data. These are the Anarchy classes for those.
ActivityProperties: Universal properties class. Cannot be used for ActivityType.Streaming.
GameActivityProperties: Allows for extra detail like how much time has elapsed and the game's state.
StreamActivityProperties: For .Streaming. .Url must be set to a Twitch channel.
DiscordActivity: Universal class.
DiscordGameActivity: For .Game.
DiscordListeningActivity: For .Listening (for example Spotify).
CustomStatusActivity: For .CustomStatus.
client.UpdatePresence(new PresenceProperties(){Status = UserStatus.DoNotDisturb,Activity = new StreamActivityProperties() { Name = "Powered by Anarchy", Url = "https://twitch.tv/ilinked" }});
The methods .SetStatus() and .SetActivity() are also available.
Anarchy does not cache presences, meaning that the only way to receive presences from other users is the OnUserPresenceUpdated event.
private void client_OnUserPresenceUpdated(DiscordSocketClient client, PresenceUpdatedEventArgs args){if (args.Presence.ActivePlatforms.Mobile > UserStatus.Offline)client.CreateDM(args.Presence.UserId).SendMessage("ew mobile user");}
If DiscordPresence.IsGuild is true, DiscordPresence can be casted to a DiscordGuildPresence to reveal more information.
Like presences, voice states are only available through gateway clients. Anarchy provides several methods to serve you voice states through the cache, although the OnVoiceStateUpdated event is also available.
DiscordVoiceStateContainer userStates = client.GetVoiceStates(42069); // for users​// These 2 only return voice states where the user is connected to the object. The previous does notIReadOnlyList<DiscordVoiceState> guildStates = client.GetGuildVoiceStates(44492); // for guildsIReadOnlyList<DiscordVoiceState> channelStates = client.GetChannelVoiceStates(44493); // for channels
This class exists because bots can be connected to multiple channels at the same time and users can be muted even tho they're not connected to the channel. It's a way of neatly packing everything together.
As said previously, the OnVoiceStateUpdated event can be used to detect voice state updates. Here's an example of how a listener could look.
private void client_OnVoiceStateUpdated(DiscordSocketClient client, VoiceStateEventArgs args){Console.WriteLine(args.State.UserId + " updated their voice state. Current channel: "+ (args.State.Channel == null ? "none" : args.State.Channel.Id));}
Modifying your own voice state through Anarchy is actually rather simple. Consider the following example.
client.ChangeVoiceState(new VoiceStateProperties(){ChannelId = 745209696939409460,Muted = true});
Setting GuildId is not necessary if you have caching enabled. If you're on a bot account and want to disconnect from a voice channel, make sure to specify the GuildId as ChannelId will be null.
This plays a role in connecting to voice channels, which you can read about below.
Relationships the term used for friends and blocked users.
// This would be shown as yeahwoo#9943 in the UIclient.SendFriendRequest("yeahwoo", 9943);​client.BlockUser(711776878444412928);
Passing a user who's sent you a friend request to .SendFriendRequest() will accept their request.
Anarchy has a single method for removing all types of relationships.
foreach (var relationship in client.GetRelationships())relationship.Remove(); // or client.RemoveRelationship()