Anarchy
Search…
Users

Client users

Profile vs. settings

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.

Modifying profiles

1
client.User.ChangeProfile(new UserProfileUpdate()
2
{
3
Username = "kekmeister9000",
4
Avatar = Image.FromFile("avatar.png"),
5
Password = "ihateniggers123" // password must be provided when changing username, email, discriminator or password
6
});
Copied!
"Discriminator" is the technical term for the 4 digit number after the #.

Modifying settings

1
client.User.ChangeSettings(new UserSettingsProperties()
2
{
3
Theme = DiscordTheme.Light,
4
DeveloperMode = true,
5
Language = DiscordLanguage.Spanish,
6
CustomStatus = new CustomStatus()
7
{
8
Text = "killing jews",
9
EmojiName = "🔥" // remember to pass EmojiId if it's a custom emoji
10
}
11
});
Copied!
The UserSettingsProperties class isn't complete, although it contains the most common settings.

Badges

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

Hypesquad badges are, in fact, the only badges that you can just go out of your way modify.
1
client.User.SetHypesquad(Hypesquad.Brilliance);
2
client.User.Update(); // Hypesquad doesn't update automatically. my bad...
3
4
client.User.Badges.HasFlag(DiscordBadge.HypeBrilliance); // returns true
5
client.User.Hypesquad == Hypesquad.Balance // returns false
Copied!
The Hypesquad badges also exist within DiscordBadge; it's mostly for convenience.

Presences

Presences are users' statuses and activities. They're only available for Gateway clients.

Activity classes

Discord has different types of activities, all with their own special data. These are the Anarchy classes for those.

Properties (for setting your own)

  • 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.

From other users

  • DiscordActivity: Universal class.
  • DiscordGameActivity: For .Game.
  • DiscordListeningActivity: For .Listening (for example Spotify).
  • CustomStatusActivity: For .CustomStatus.

Updating your presence

1
client.UpdatePresence(new PresenceProperties()
2
{
3
Status = UserStatus.DoNotDisturb,
4
Activity = new StreamActivityProperties() { Name = "Powered by Anarchy", Url = "https://twitch.tv/ilinked" }
5
});
Copied!
The methods .SetStatus() and .SetActivity() are also available.

Receiving presences

Anarchy does not cache presences, meaning that the only way to receive presences from other users is the OnUserPresenceUpdated event.
1
private void client_OnUserPresenceUpdated(DiscordSocketClient client, PresenceUpdatedEventArgs args)
2
{
3
if (args.Presence.ActivePlatforms.Mobile > UserStatus.Offline)
4
client.CreateDM(args.Presence.UserId).SendMessage("ew mobile user");
5
}
Copied!
If DiscordPresence.IsGuild is true, DiscordPresence can be casted to a DiscordGuildPresence to reveal more information.

Voice states

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.

Through cache

1
DiscordVoiceStateContainer userStates = client.GetVoiceStates(42069); // for users
2
3
// These 2 only return voice states where the user is connected to the object. The previous does not
4
IReadOnlyList<DiscordVoiceState> guildStates = client.GetGuildVoiceStates(44492); // for guilds
5
IReadOnlyList<DiscordVoiceState> channelStates = client.GetChannelVoiceStates(44493); // for channels
Copied!

DiscordVoiceStateContainer

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.

Through events

As said previously, the OnVoiceStateUpdated event can be used to detect voice state updates. Here's an example of how a listener could look.
1
private void client_OnVoiceStateUpdated(DiscordSocketClient client, VoiceStateEventArgs args)
2
{
3
Console.WriteLine(args.State.UserId + " updated their voice state. Current channel: "
4
+ (args.State.Channel == null ? "none" : args.State.Channel.Id));
5
}
Copied!

Modifying your own

Modifying your own voice state through Anarchy is actually rather simple. Consider the following example.
1
client.ChangeVoiceState(new VoiceStateProperties()
2
{
3
ChannelId = 745209696939409460,
4
Muted = true
5
});
Copied!
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

Relationships the term used for friends and blocked users.

Adding relationships

1
// This would be shown as yeahwoo#9943 in the UI
2
client.SendFriendRequest("yeahwoo", 9943);
3
4
client.BlockUser(711776878444412928);
Copied!
Passing a user who's sent you a friend request to .SendFriendRequest() will accept their request.

Removing relationships

Anarchy has a single method for removing all types of relationships.
1
foreach (var relationship in client.GetRelationships())
2
relationship.Remove(); // or client.RemoveRelationship()
Copied!
Last modified 1yr ago