@@ -51,9 +51,9 @@ namespace Discord | |||||
/// Gets the date and time for when this user's guild boost began. | /// Gets the date and time for when this user's guild boost began. | ||||
/// </summary> | /// </summary> | ||||
/// <returns> | /// <returns> | ||||
/// A <see cref="DateTime"/> for when the user began boosting this guild; <c>null</c> if they are not boosting the guild. | |||||
/// A <see cref="DateTimeOffset"/> for when the user began boosting this guild; <c>null</c> if they are not boosting the guild. | |||||
/// </returns> | /// </returns> | ||||
DateTime? PremiumSince { get; } | |||||
DateTimeOffset? PremiumSince { get; } | |||||
/// <summary> | /// <summary> | ||||
/// Gets a collection of IDs for the roles that this user currently possesses in the guild. | /// Gets a collection of IDs for the roles that this user currently possesses in the guild. | ||||
/// </summary> | /// </summary> | ||||
@@ -18,7 +18,7 @@ namespace Discord.API | |||||
public Optional<bool> Deaf { get; set; } | public Optional<bool> Deaf { get; set; } | ||||
[JsonProperty("mute")] | [JsonProperty("mute")] | ||||
public Optional<bool> Mute { get; set; } | public Optional<bool> Mute { get; set; } | ||||
[JsonProperty("premium_guild_since")] | |||||
public Optional<DateTime> PremiumSince { get; set; } | |||||
[JsonProperty("premium_since")] | |||||
public Optional<DateTimeOffset?> PremiumSince { get; set; } | |||||
} | } | ||||
} | } |
@@ -14,6 +14,7 @@ namespace Discord.Rest | |||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] | [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | ||||
public class RestGuildUser : RestUser, IGuildUser | public class RestGuildUser : RestUser, IGuildUser | ||||
{ | { | ||||
private long? _premiumSinceTicks; | |||||
private long? _joinedAtTicks; | private long? _joinedAtTicks; | ||||
private ImmutableArray<ulong> _roleIds; | private ImmutableArray<ulong> _roleIds; | ||||
@@ -25,7 +26,7 @@ namespace Discord.Rest | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public bool IsMuted { get; private set; } | public bool IsMuted { get; private set; } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public DateTime? PremiumSince { get; private set; } | |||||
public DateTimeOffset? PremiumSince => DateTimeUtils.FromTicks(_premiumSinceTicks); | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public ulong GuildId => Guild.Id; | public ulong GuildId => Guild.Id; | ||||
@@ -71,7 +72,7 @@ namespace Discord.Rest | |||||
if (model.Roles.IsSpecified) | if (model.Roles.IsSpecified) | ||||
UpdateRoles(model.Roles.Value); | UpdateRoles(model.Roles.Value); | ||||
if (model.PremiumSince.IsSpecified) | if (model.PremiumSince.IsSpecified) | ||||
PremiumSince = model.PremiumSince.Value; | |||||
_premiumSinceTicks = model.PremiumSince.Value?.UtcTicks; | |||||
} | } | ||||
private void UpdateRoles(ulong[] roleIds) | private void UpdateRoles(ulong[] roleIds) | ||||
{ | { | ||||
@@ -14,7 +14,7 @@ namespace Discord.Rest | |||||
public ulong WebhookId { get; } | public ulong WebhookId { get; } | ||||
internal IGuild Guild { get; } | internal IGuild Guild { get; } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public DateTime? PremiumSince { get; private set; } | |||||
public DateTimeOffset? PremiumSince { get; private set; } | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public override bool IsWebhook => true; | public override bool IsWebhook => true; | ||||
@@ -18,6 +18,7 @@ namespace Discord.WebSocket | |||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] | [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | ||||
public class SocketGuildUser : SocketUser, IGuildUser | public class SocketGuildUser : SocketUser, IGuildUser | ||||
{ | { | ||||
private long? _premiumSinceTicks; | |||||
private long? _joinedAtTicks; | private long? _joinedAtTicks; | ||||
private ImmutableArray<ulong> _roleIds; | private ImmutableArray<ulong> _roleIds; | ||||
@@ -75,9 +76,8 @@ namespace Discord.WebSocket | |||||
/// </returns> | /// </returns> | ||||
public SocketVoiceState? VoiceState => Guild.GetVoiceState(Id); | public SocketVoiceState? VoiceState => Guild.GetVoiceState(Id); | ||||
public AudioInStream AudioStream => Guild.GetAudioStream(Id); | public AudioInStream AudioStream => Guild.GetAudioStream(Id); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public DateTime? PremiumSince { get; private set; } | |||||
public DateTimeOffset? PremiumSince => DateTimeUtils.FromTicks(_premiumSinceTicks); | |||||
/// <summary> | /// <summary> | ||||
/// Returns the position of the user within the role hierarchy. | /// Returns the position of the user within the role hierarchy. | ||||
@@ -138,6 +138,8 @@ namespace Discord.WebSocket | |||||
Nickname = model.Nick.Value; | Nickname = model.Nick.Value; | ||||
if (model.Roles.IsSpecified) | if (model.Roles.IsSpecified) | ||||
UpdateRoles(model.Roles.Value); | UpdateRoles(model.Roles.Value); | ||||
if (model.PremiumSince.IsSpecified) | |||||
_premiumSinceTicks = model.PremiumSince.Value?.UtcTicks; | |||||
} | } | ||||
internal void Update(ClientState state, PresenceModel model, bool updatePresence) | internal void Update(ClientState state, PresenceModel model, bool updatePresence) | ||||
{ | { | ||||
@@ -63,7 +63,7 @@ namespace Discord.WebSocket | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
string IGuildUser.Nickname => null; | string IGuildUser.Nickname => null; | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
DateTime? IGuildUser.PremiumSince => null; | |||||
DateTimeOffset? IGuildUser.PremiumSince => null; | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
GuildPermissions IGuildUser.GuildPermissions => GuildPermissions.Webhook; | GuildPermissions IGuildUser.GuildPermissions => GuildPermissions.Webhook; | ||||