* Add self_stream voice state property Adds the self_stream property which is set true when a user is streaming a video to a voice channel * use flags for selfstream state instead of its own proptags/2.2.0
@@ -55,5 +55,12 @@ namespace Discord | |||||
/// Gets the unique identifier for this user's voice session. | /// Gets the unique identifier for this user's voice session. | ||||
/// </summary> | /// </summary> | ||||
string VoiceSessionId { get; } | string VoiceSessionId { get; } | ||||
/// <summary> | |||||
/// Gets a value that indicates if this user is streaming in a voice channel. | |||||
/// </summary> | |||||
/// <returns> | |||||
/// <c>true</c> if the user is streaming; otherwise <c>false</c>. | |||||
/// </returns> | |||||
bool IsStream { get; } | |||||
} | } | ||||
} | } |
@@ -26,5 +26,7 @@ namespace Discord.API | |||||
public bool SelfMute { get; set; } | public bool SelfMute { get; set; } | ||||
[JsonProperty("suppress")] | [JsonProperty("suppress")] | ||||
public bool Suppress { get; set; } | public bool Suppress { get; set; } | ||||
[JsonProperty("self_stream")] | |||||
public bool SelfStream { get; set; } | |||||
} | } | ||||
} | } |
@@ -35,5 +35,7 @@ namespace Discord.Rest | |||||
IVoiceChannel IVoiceState.VoiceChannel => null; | IVoiceChannel IVoiceState.VoiceChannel => null; | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
string IVoiceState.VoiceSessionId => null; | string IVoiceState.VoiceSessionId => null; | ||||
/// <inheritdoc /> | |||||
bool IVoiceState.IsStream => false; | |||||
} | } | ||||
} | } |
@@ -151,5 +151,7 @@ namespace Discord.Rest | |||||
IVoiceChannel IVoiceState.VoiceChannel => null; | IVoiceChannel IVoiceState.VoiceChannel => null; | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
string IVoiceState.VoiceSessionId => null; | string IVoiceState.VoiceSessionId => null; | ||||
/// <inheritdoc /> | |||||
bool IVoiceState.IsStream => false; | |||||
} | } | ||||
} | } |
@@ -95,5 +95,7 @@ namespace Discord.Rest | |||||
IVoiceChannel IVoiceState.VoiceChannel => null; | IVoiceChannel IVoiceState.VoiceChannel => null; | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
string IVoiceState.VoiceSessionId => null; | string IVoiceState.VoiceSessionId => null; | ||||
/// <inheritdoc /> | |||||
bool IVoiceState.IsStream => false; | |||||
} | } | ||||
} | } |
@@ -61,5 +61,7 @@ namespace Discord.WebSocket | |||||
IVoiceChannel IVoiceState.VoiceChannel => null; | IVoiceChannel IVoiceState.VoiceChannel => null; | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
string IVoiceState.VoiceSessionId => null; | string IVoiceState.VoiceSessionId => null; | ||||
/// <inheritdoc /> | |||||
bool IVoiceState.IsStream => false; | |||||
} | } | ||||
} | } |
@@ -55,6 +55,8 @@ namespace Discord.WebSocket | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public bool IsMuted => VoiceState?.IsMuted ?? false; | public bool IsMuted => VoiceState?.IsMuted ?? false; | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public bool IsStream => VoiceState?.IsStream ?? false; | |||||
/// <inheritdoc /> | |||||
public DateTimeOffset? JoinedAt => DateTimeUtils.FromTicks(_joinedAtTicks); | public DateTimeOffset? JoinedAt => DateTimeUtils.FromTicks(_joinedAtTicks); | ||||
/// <summary> | /// <summary> | ||||
/// Returns a collection of roles that the user possesses. | /// Returns a collection of roles that the user possesses. | ||||
@@ -13,7 +13,7 @@ namespace Discord.WebSocket | |||||
/// <summary> | /// <summary> | ||||
/// Initializes a default <see cref="SocketVoiceState"/> with everything set to <c>null</c> or <c>false</c>. | /// Initializes a default <see cref="SocketVoiceState"/> with everything set to <c>null</c> or <c>false</c>. | ||||
/// </summary> | /// </summary> | ||||
public static readonly SocketVoiceState Default = new SocketVoiceState(null, null, false, false, false, false, false); | |||||
public static readonly SocketVoiceState Default = new SocketVoiceState(null, null, false, false, false, false, false, false); | |||||
[Flags] | [Flags] | ||||
private enum Flags : byte | private enum Flags : byte | ||||
@@ -24,6 +24,7 @@ namespace Discord.WebSocket | |||||
Deafened = 0x04, | Deafened = 0x04, | ||||
SelfMuted = 0x08, | SelfMuted = 0x08, | ||||
SelfDeafened = 0x10, | SelfDeafened = 0x10, | ||||
SelfStream = 0x20, | |||||
} | } | ||||
private readonly Flags _voiceStates; | private readonly Flags _voiceStates; | ||||
@@ -45,8 +46,10 @@ namespace Discord.WebSocket | |||||
public bool IsSelfMuted => (_voiceStates & Flags.SelfMuted) != 0; | public bool IsSelfMuted => (_voiceStates & Flags.SelfMuted) != 0; | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public bool IsSelfDeafened => (_voiceStates & Flags.SelfDeafened) != 0; | public bool IsSelfDeafened => (_voiceStates & Flags.SelfDeafened) != 0; | ||||
/// <inheritdoc /> | |||||
public bool IsStream => (_voiceStates & Flags.SelfStream) != 0; | |||||
internal SocketVoiceState(SocketVoiceChannel voiceChannel, string sessionId, bool isSelfMuted, bool isSelfDeafened, bool isMuted, bool isDeafened, bool isSuppressed) | |||||
internal SocketVoiceState(SocketVoiceChannel voiceChannel, string sessionId, bool isSelfMuted, bool isSelfDeafened, bool isMuted, bool isDeafened, bool isSuppressed, bool isStream) | |||||
{ | { | ||||
VoiceChannel = voiceChannel; | VoiceChannel = voiceChannel; | ||||
VoiceSessionId = sessionId; | VoiceSessionId = sessionId; | ||||
@@ -62,11 +65,13 @@ namespace Discord.WebSocket | |||||
voiceStates |= Flags.Deafened; | voiceStates |= Flags.Deafened; | ||||
if (isSuppressed) | if (isSuppressed) | ||||
voiceStates |= Flags.Suppressed; | voiceStates |= Flags.Suppressed; | ||||
if (isStream) | |||||
voiceStates |= Flags.SelfStream; | |||||
_voiceStates = voiceStates; | _voiceStates = voiceStates; | ||||
} | } | ||||
internal static SocketVoiceState Create(SocketVoiceChannel voiceChannel, Model model) | internal static SocketVoiceState Create(SocketVoiceChannel voiceChannel, Model model) | ||||
{ | { | ||||
return new SocketVoiceState(voiceChannel, model.SessionId, model.SelfMute, model.SelfDeaf, model.Mute, model.Deaf, model.Suppress); | |||||
return new SocketVoiceState(voiceChannel, model.SessionId, model.SelfMute, model.SelfDeaf, model.Mute, model.Deaf, model.Suppress, model.SelfStream); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -114,5 +114,7 @@ namespace Discord.WebSocket | |||||
IVoiceChannel IVoiceState.VoiceChannel => null; | IVoiceChannel IVoiceState.VoiceChannel => null; | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
string IVoiceState.VoiceSessionId => null; | string IVoiceState.VoiceSessionId => null; | ||||
/// <inheritdoc /> | |||||
bool IVoiceState.IsStream => false; | |||||
} | } | ||||
} | } |