Browse Source

Made IVoiceChannel.UserLimit nullable

tags/1.0-rc
RogueException 8 years ago
parent
commit
ea0044cb87
6 changed files with 13 additions and 16 deletions
  1. +2
    -2
      src/Discord.Net.Core/Entities/Channels/IVoiceChannel.cs
  2. +1
    -1
      src/Discord.Net.Core/Entities/Channels/VoiceChannelProperties.cs
  3. +1
    -1
      src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs
  4. +3
    -4
      src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs
  5. +3
    -4
      src/Discord.Net.Rpc/Entities/Channels/RpcVoiceChannel.cs
  6. +3
    -4
      src/Discord.Net.WebSocket/Entities/Channels/SocketVoiceChannel.cs

+ 2
- 2
src/Discord.Net.Core/Entities/Channels/IVoiceChannel.cs View File

@@ -8,8 +8,8 @@ namespace Discord
{
/// <summary> Gets the bitrate, in bits per second, clients in this voice channel are requested to use. </summary>
int Bitrate { get; }
/// <summary> Gets the max amount of users allowed to be connected to this channel at one time. A value of 0 represents no limit. </summary>
int UserLimit { get; }
/// <summary> Gets the max amount of users allowed to be connected to this channel at one time. </summary>
int? UserLimit { get; }

/// <summary> Modifies this voice channel. </summary>
Task ModifyAsync(Action<VoiceChannelProperties> func, RequestOptions options = null);


+ 1
- 1
src/Discord.Net.Core/Entities/Channels/VoiceChannelProperties.cs View File

@@ -10,6 +10,6 @@
/// <summary>
/// The maximum number of users that can be present in a channel.
/// </summary>
public Optional<int> UserLimit { get; set; }
public Optional<int?> UserLimit { get; set; }
}
}

+ 1
- 1
src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs View File

@@ -56,7 +56,7 @@ namespace Discord.Rest
Bitrate = args.Bitrate,
Name = args.Name,
Position = args.Position,
UserLimit = args.UserLimit
UserLimit = args.UserLimit.IsSpecified ? (args.UserLimit.Value ?? 0) : Optional.Create<int>()
};
return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false);
}


+ 3
- 4
src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs View File

@@ -1,5 +1,4 @@
using Discord.API.Rest;
using Discord.Audio;
using Discord.Audio;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -13,7 +12,7 @@ namespace Discord.Rest
public class RestVoiceChannel : RestGuildChannel, IVoiceChannel, IRestAudioChannel
{
public int Bitrate { get; private set; }
public int UserLimit { get; private set; }
public int? UserLimit { get; private set; }

internal RestVoiceChannel(BaseDiscordClient discord, IGuild guild, ulong id)
: base(discord, guild, id)
@@ -30,7 +29,7 @@ namespace Discord.Rest
base.Update(model);

Bitrate = model.Bitrate.Value;
UserLimit = model.UserLimit.Value;
UserLimit = model.UserLimit.Value != 0 ? model.UserLimit.Value : (int?)null;
}

public async Task ModifyAsync(Action<VoiceChannelProperties> func, RequestOptions options = null)


+ 3
- 4
src/Discord.Net.Rpc/Entities/Channels/RpcVoiceChannel.cs View File

@@ -1,5 +1,4 @@
using Discord.API.Rest;
using Discord.Audio;
using Discord.Audio;
using Discord.Rest;
using System;
using System.Collections.Generic;
@@ -14,8 +13,8 @@ namespace Discord.Rpc
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class RpcVoiceChannel : RpcGuildChannel, IRpcAudioChannel, IVoiceChannel
{
public int UserLimit { get; private set; }
public int Bitrate { get; private set; }
public int? UserLimit { get; private set; }
public IReadOnlyCollection<RpcVoiceState> VoiceStates { get; private set; }

internal RpcVoiceChannel(DiscordRpcClient discord, ulong id, ulong guildId)
@@ -32,7 +31,7 @@ namespace Discord.Rpc
{
base.Update(model);
if (model.UserLimit.IsSpecified)
UserLimit = model.UserLimit.Value;
UserLimit = model.UserLimit.Value != 0 ? model.UserLimit.Value : (int?)null;
if (model.Bitrate.IsSpecified)
Bitrate = model.Bitrate.Value;
VoiceStates = model.VoiceStates.Select(x => RpcVoiceState.Create(Discord, x)).ToImmutableArray();


+ 3
- 4
src/Discord.Net.WebSocket/Entities/Channels/SocketVoiceChannel.cs View File

@@ -1,5 +1,4 @@
using Discord.API.Rest;
using Discord.Audio;
using Discord.Audio;
using Discord.Rest;
using System;
using System.Collections.Generic;
@@ -15,7 +14,7 @@ namespace Discord.WebSocket
public class SocketVoiceChannel : SocketGuildChannel, IVoiceChannel, ISocketAudioChannel
{
public int Bitrate { get; private set; }
public int UserLimit { get; private set; }
public int? UserLimit { get; private set; }

public override IReadOnlyCollection<SocketGuildUser> Users
=> Guild.Users.Where(x => x.VoiceChannel?.Id == Id).ToImmutableArray();
@@ -35,7 +34,7 @@ namespace Discord.WebSocket
base.Update(state, model);

Bitrate = model.Bitrate.Value;
UserLimit = model.UserLimit.Value;
UserLimit = model.UserLimit.Value != 0 ? model.UserLimit.Value : (int?)null;
}

public Task ModifyAsync(Action<VoiceChannelProperties> func, RequestOptions options = null)


Loading…
Cancel
Save