@@ -0,0 +1,19 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace Discord | |||||
{ | |||||
[Flags] | |||||
public enum ActivityFlag | |||||
{ | |||||
Instance = 1, | |||||
Join = 0b10, | |||||
Spectate = 0b100, | |||||
JoinRequest = 0b1000, | |||||
Sync = 0b10000, | |||||
Play = 0b100000 | |||||
} | |||||
} |
@@ -0,0 +1,31 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace Discord | |||||
{ | |||||
[Flags] | |||||
public enum UserFlag | |||||
{ | |||||
/// <summary> | |||||
/// Default value for flags, when none are given to an account. | |||||
/// </summary> | |||||
None = 0, | |||||
/// <summary> | |||||
/// Flag given to Discord staff. | |||||
/// </summary> | |||||
Staff = 0b1, | |||||
/// <summary> | |||||
/// Flag given to Discord partners. | |||||
/// </summary> | |||||
Partner = 0b10, | |||||
HypeSquadEvents = 0b100, | |||||
BugHunter = 0b1000, | |||||
HypeSquadBravery = 0b100_0000, | |||||
HypeSquadBrilliance = 0b1000_0000, | |||||
HypeSquadBalance = 0b1_0000_0000, | |||||
EarlySupporter = 0b10_0000_0000, | |||||
} | |||||
} |
@@ -0,0 +1,17 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace Discord | |||||
{ | |||||
/// <summary> | |||||
/// Extension methods for the <see cref="IActivity"/> types. | |||||
/// </summary> | |||||
public static class ActivityExtensions | |||||
{ | |||||
public static bool CheckFlag(this IActivity activity, ActivityFlag flag) | |||||
=> (activity.Flags & (int)flag) >= (int)flag; | |||||
} | |||||
} |
@@ -160,5 +160,8 @@ namespace Discord | |||||
/// </returns> | /// </returns> | ||||
public static Task BanAsync(this IGuildUser user, int pruneDays = 0, string reason = null, RequestOptions options = null) | public static Task BanAsync(this IGuildUser user, int pruneDays = 0, string reason = null, RequestOptions options = null) | ||||
=> user.Guild.AddBanAsync(user, pruneDays, reason, options); | => user.Guild.AddBanAsync(user, pruneDays, reason, options); | ||||
public static bool CheckUserFlag(this IUser user, UserFlag flag) | |||||
=> (user.Flags & (int)flag) >= (int)flag; | |||||
} | } | ||||
} | } |
@@ -33,6 +33,8 @@ namespace Discord.API | |||||
public Optional<string> SyncId { get; set; } | public Optional<string> SyncId { get; set; } | ||||
[JsonProperty("session_id")] | [JsonProperty("session_id")] | ||||
public Optional<string> SessionId { get; set; } | public Optional<string> SessionId { get; set; } | ||||
[JsonProperty("Flags")] | |||||
public Optional<int> Flags { get; set; } | |||||
[OnError] | [OnError] | ||||
internal void OnError(StreamingContext context, ErrorContext errorContext) | internal void OnError(StreamingContext context, ErrorContext errorContext) | ||||
@@ -1,4 +1,4 @@ | |||||
#pragma warning disable CS1591 | |||||
#pragma warning disable CS1591 | |||||
using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
namespace Discord.API | namespace Discord.API | ||||
@@ -23,5 +23,9 @@ namespace Discord.API | |||||
public Optional<string> Email { get; set; } | public Optional<string> Email { get; set; } | ||||
[JsonProperty("mfa_enabled")] | [JsonProperty("mfa_enabled")] | ||||
public Optional<bool> MfaEnabled { get; set; } | public Optional<bool> MfaEnabled { get; set; } | ||||
[JsonProperty("flags")] | |||||
public Optional<int> Flags { get; set; } | |||||
[JsonProperty("premium_type")] | |||||
public Optional<PremiumType> PremiumType { get; set; } | |||||
} | } | ||||
} | } |
@@ -63,6 +63,10 @@ namespace Discord.Rest | |||||
IsBot = model.Bot.Value; | IsBot = model.Bot.Value; | ||||
if (model.Username.IsSpecified) | if (model.Username.IsSpecified) | ||||
Username = model.Username.Value; | Username = model.Username.Value; | ||||
if (model.Flags.IsSpecified) | |||||
Flags = model.Flags.Value; | |||||
if (model.PremiumType.IsSpecified) | |||||
PremiumType = model.PremiumType.Value; | |||||
} | } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
@@ -194,5 +194,6 @@ namespace Discord.WebSocket | |||||
//IVoiceState | //IVoiceState | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
IVoiceChannel IVoiceState.VoiceChannel => VoiceChannel; | IVoiceChannel IVoiceState.VoiceChannel => VoiceChannel; | ||||
} | } | ||||
} | } |
@@ -38,6 +38,11 @@ namespace Discord.WebSocket | |||||
public IActivity Activity => Presence.Activity; | public IActivity Activity => Presence.Activity; | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public UserStatus Status => Presence.Status; | public UserStatus Status => Presence.Status; | ||||
/// <inheritdoc /> | |||||
public int Flags { get; internal set; } | |||||
/// <inheritdoc /> | |||||
public PremiumType? PremiumType { get; internal set; } | |||||
/// <summary> | /// <summary> | ||||
/// Gets mutual guilds shared with this user. | /// Gets mutual guilds shared with this user. | ||||
/// </summary> | /// </summary> | ||||
@@ -75,6 +80,16 @@ namespace Discord.WebSocket | |||||
Username = model.Username.Value; | Username = model.Username.Value; | ||||
hasChanges = true; | hasChanges = true; | ||||
} | } | ||||
if (model.Flags.IsSpecified && model.Flags.Value != Flags) | |||||
{ | |||||
Flags = model.Flags.Value; | |||||
hasChanges = true; | |||||
} | |||||
if (model.PremiumType.IsSpecified && model.PremiumType.Value != PremiumType) | |||||
{ | |||||
PremiumType = model.PremiumType.Value; | |||||
hasChanges = true; | |||||
} | |||||
return hasChanges; | return hasChanges; | ||||
} | } | ||||
@@ -25,7 +25,8 @@ namespace Discord.WebSocket | |||||
Artists = model.State.GetValueOrDefault()?.Split(';').Select(x=>x?.Trim()).ToImmutableArray(), | Artists = model.State.GetValueOrDefault()?.Split(';').Select(x=>x?.Trim()).ToImmutableArray(), | ||||
Duration = timestamps?.End - timestamps?.Start, | Duration = timestamps?.End - timestamps?.Start, | ||||
AlbumArtUrl = albumArtId != null ? CDN.GetSpotifyAlbumArtUrl(albumArtId) : null, | AlbumArtUrl = albumArtId != null ? CDN.GetSpotifyAlbumArtUrl(albumArtId) : null, | ||||
Type = ActivityType.Listening | |||||
Type = ActivityType.Listening, | |||||
Flags = model.Flags.GetValueOrDefault() | |||||
}; | }; | ||||
} | } | ||||
@@ -44,14 +45,15 @@ namespace Discord.WebSocket | |||||
LargeAsset = assets?[1], | LargeAsset = assets?[1], | ||||
Party = model.Party.IsSpecified ? model.Party.Value.ToEntity() : null, | Party = model.Party.IsSpecified ? model.Party.Value.ToEntity() : null, | ||||
Secrets = model.Secrets.IsSpecified ? model.Secrets.Value.ToEntity() : null, | Secrets = model.Secrets.IsSpecified ? model.Secrets.Value.ToEntity() : null, | ||||
Timestamps = model.Timestamps.IsSpecified ? model.Timestamps.Value.ToEntity() : null | |||||
Timestamps = model.Timestamps.IsSpecified ? model.Timestamps.Value.ToEntity() : null, | |||||
Flags = model.Flags.GetValueOrDefault() | |||||
}; | }; | ||||
} | } | ||||
// Stream Game | // Stream Game | ||||
if (model.StreamUrl.IsSpecified) | if (model.StreamUrl.IsSpecified) | ||||
{ | { | ||||
return new StreamingGame( | return new StreamingGame( | ||||
model.Name, | |||||
model.Name, | |||||
model.StreamUrl.Value); | model.StreamUrl.Value); | ||||
} | } | ||||
// Normal Game | // Normal Game | ||||