Browse Source

Add self_video to VoiceState (#2137)

* Add self_video to VoiceState

* Update selfVideo flag
tags/3.4.0
EpicOfficer GitHub 3 years ago
parent
commit
8bcd3da9e4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 33 additions and 3 deletions
  1. +7
    -0
      src/Discord.Net.Core/Entities/Users/IVoiceState.cs
  2. +2
    -0
      src/Discord.Net.Rest/API/Common/VoiceState.cs
  3. +2
    -0
      src/Discord.Net.Rest/Entities/Users/RestGroupUser.cs
  4. +2
    -0
      src/Discord.Net.Rest/Entities/Users/RestGuildUser.cs
  5. +2
    -0
      src/Discord.Net.Rest/Entities/Users/RestWebhookUser.cs
  6. +2
    -0
      src/Discord.Net.WebSocket/Entities/Users/SocketGroupUser.cs
  7. +2
    -0
      src/Discord.Net.WebSocket/Entities/Users/SocketGuildUser.cs
  8. +4
    -0
      src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs
  9. +8
    -3
      src/Discord.Net.WebSocket/Entities/Users/SocketVoiceState.cs
  10. +2
    -0
      src/Discord.Net.WebSocket/Entities/Users/SocketWebhookUser.cs

+ 7
- 0
src/Discord.Net.Core/Entities/Users/IVoiceState.cs View File

@@ -65,6 +65,13 @@ namespace Discord
/// </returns>
bool IsStreaming { get; }
/// <summary>
/// Gets a value that indicates if the user is videoing in a voice channel.
/// </summary>
/// <returns>
/// <c>true</c> if the user has their camera turned on; otherwise <c>false</c>.
/// </returns>
bool IsVideoing { get; }
/// <summary>
/// Gets the time on which the user requested to speak.
/// </summary>
DateTimeOffset? RequestToSpeakTimestamp { get; }


+ 2
- 0
src/Discord.Net.Rest/API/Common/VoiceState.cs View File

@@ -28,6 +28,8 @@ namespace Discord.API
public bool Suppress { get; set; }
[JsonProperty("self_stream")]
public bool SelfStream { get; set; }
[JsonProperty("self_video")]
public bool SelfVideo { get; set; }
[JsonProperty("request_to_speak_timestamp")]
public Optional<DateTimeOffset?> RequestToSpeakTimestamp { get; set; }
}


+ 2
- 0
src/Discord.Net.Rest/Entities/Users/RestGroupUser.cs View File

@@ -41,6 +41,8 @@ namespace Discord.Rest
/// <inheritdoc />
bool IVoiceState.IsStreaming => false;
/// <inheritdoc />
bool IVoiceState.IsVideoing => false;
/// <inheritdoc />
DateTimeOffset? IVoiceState.RequestToSpeakTimestamp => null;
#endregion
}


+ 2
- 0
src/Discord.Net.Rest/Entities/Users/RestGuildUser.cs View File

@@ -223,6 +223,8 @@ namespace Discord.Rest
/// <inheritdoc />
bool IVoiceState.IsStreaming => false;
/// <inheritdoc />
bool IVoiceState.IsVideoing => false;
/// <inheritdoc />
DateTimeOffset? IVoiceState.RequestToSpeakTimestamp => null;
#endregion
}


+ 2
- 0
src/Discord.Net.Rest/Entities/Users/RestWebhookUser.cs View File

@@ -131,6 +131,8 @@ namespace Discord.Rest
/// <inheritdoc />
bool IVoiceState.IsStreaming => false;
/// <inheritdoc />
bool IVoiceState.IsVideoing => false;
/// <inheritdoc />
DateTimeOffset? IVoiceState.RequestToSpeakTimestamp => null;
#endregion
}


+ 2
- 0
src/Discord.Net.WebSocket/Entities/Users/SocketGroupUser.cs View File

@@ -70,6 +70,8 @@ namespace Discord.WebSocket
/// <inheritdoc />
bool IVoiceState.IsStreaming => false;
/// <inheritdoc />
bool IVoiceState.IsVideoing => false;
/// <inheritdoc />
DateTimeOffset? IVoiceState.RequestToSpeakTimestamp => null;
#endregion
}


+ 2
- 0
src/Discord.Net.WebSocket/Entities/Users/SocketGuildUser.cs View File

@@ -65,6 +65,8 @@ namespace Discord.WebSocket
/// <inheritdoc />
public bool IsStreaming => VoiceState?.IsStreaming ?? false;
/// <inheritdoc />
public bool IsVideoing => VoiceState?.IsVideoing ?? false;
/// <inheritdoc />
public DateTimeOffset? RequestToSpeakTimestamp => VoiceState?.RequestToSpeakTimestamp ?? null;
/// <inheritdoc />
public bool? IsPending { get; private set; }


+ 4
- 0
src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs View File

@@ -122,6 +122,10 @@ namespace Discord.WebSocket
public bool IsStreaming
=> GuildUser.IsStreaming;

/// <inheritdoc/>
public bool IsVideoing
=> GuildUser.IsVideoing;

/// <inheritdoc/>
public DateTimeOffset? RequestToSpeakTimestamp
=> GuildUser.RequestToSpeakTimestamp;


+ 8
- 3
src/Discord.Net.WebSocket/Entities/Users/SocketVoiceState.cs View File

@@ -13,7 +13,7 @@ namespace Discord.WebSocket
/// <summary>
/// Initializes a default <see cref="SocketVoiceState"/> with everything set to <c>null</c> or <c>false</c>.
/// </summary>
public static readonly SocketVoiceState Default = new SocketVoiceState(null, null, null, false, false, false, false, false, false);
public static readonly SocketVoiceState Default = new SocketVoiceState(null, null, null, false, false, false, false, false, false, false);

[Flags]
private enum Flags : byte
@@ -25,6 +25,7 @@ namespace Discord.WebSocket
SelfMuted = 0x08,
SelfDeafened = 0x10,
SelfStream = 0x20,
SelfVideo = 0x40,
}

private readonly Flags _voiceStates;
@@ -50,9 +51,11 @@ namespace Discord.WebSocket
public bool IsSelfDeafened => (_voiceStates & Flags.SelfDeafened) != 0;
/// <inheritdoc />
public bool IsStreaming => (_voiceStates & Flags.SelfStream) != 0;
/// <inheritdoc />
public bool IsVideoing => (_voiceStates & Flags.SelfVideo) != 0;

internal SocketVoiceState(SocketVoiceChannel voiceChannel, DateTimeOffset? requestToSpeak, string sessionId, bool isSelfMuted, bool isSelfDeafened, bool isMuted, bool isDeafened, bool isSuppressed, bool isStream)
internal SocketVoiceState(SocketVoiceChannel voiceChannel, DateTimeOffset? requestToSpeak, string sessionId, bool isSelfMuted, bool isSelfDeafened, bool isMuted, bool isDeafened, bool isSuppressed, bool isStream, bool isVideo)
{
VoiceChannel = voiceChannel;
VoiceSessionId = sessionId;
@@ -71,11 +74,13 @@ namespace Discord.WebSocket
voiceStates |= Flags.Suppressed;
if (isStream)
voiceStates |= Flags.SelfStream;
if (isVideo)
voiceStates |= Flags.SelfVideo;
_voiceStates = voiceStates;
}
internal static SocketVoiceState Create(SocketVoiceChannel voiceChannel, Model model)
{
return new SocketVoiceState(voiceChannel, model.RequestToSpeakTimestamp.IsSpecified ? model.RequestToSpeakTimestamp.Value : null, model.SessionId, model.SelfMute, model.SelfDeaf, model.Mute, model.Deaf, model.Suppress, model.SelfStream);
return new SocketVoiceState(voiceChannel, model.RequestToSpeakTimestamp.IsSpecified ? model.RequestToSpeakTimestamp.Value : null, model.SessionId, model.SelfMute, model.SelfDeaf, model.Mute, model.Deaf, model.Suppress, model.SelfStream, model.SelfVideo);
}

/// <summary>


+ 2
- 0
src/Discord.Net.WebSocket/Entities/Users/SocketWebhookUser.cs View File

@@ -164,6 +164,8 @@ namespace Discord.WebSocket
/// <inheritdoc />
bool IVoiceState.IsStreaming => false;
/// <inheritdoc />
bool IVoiceState.IsVideoing => false;
/// <inheritdoc />
DateTimeOffset? IVoiceState.RequestToSpeakTimestamp => null;
#endregion
}


Loading…
Cancel
Save