From d57a7fece073a679684b571e5b36b5045f1a2e41 Mon Sep 17 00:00:00 2001 From: Chris Johnston Date: Thu, 23 May 2019 00:35:09 -0700 Subject: [PATCH] Feature: Disconnect users from voice channels Updates GuildUserProperties to allow for setting either Channel or ChannelId to null, which will disconnect users from voice channels. The type of ChannelId has been updated from a ulong to ulong?, which matches the latest api documentation. --- src/Discord.Net.Core/Entities/Users/GuildUserProperties.cs | 7 ++++--- src/Discord.Net.Rest/API/Rest/ModifyGuildMemberParams.cs | 4 ++-- src/Discord.Net.Rest/Entities/Users/UserHelper.cs | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Discord.Net.Core/Entities/Users/GuildUserProperties.cs b/src/Discord.Net.Core/Entities/Users/GuildUserProperties.cs index bea26e656..6197872fa 100644 --- a/src/Discord.Net.Core/Entities/Users/GuildUserProperties.cs +++ b/src/Discord.Net.Core/Entities/Users/GuildUserProperties.cs @@ -59,18 +59,19 @@ namespace Discord /// public Optional> RoleIds { get; set; } /// - /// Moves a user to a voice channel. + /// Moves a user to a voice channel. If null, this user will be disconnected from voice. /// /// /// This user MUST already be in a for this to work. + /// When set, this property takes precedence over . /// public Optional Channel { get; set; } /// - /// Moves a user to a voice channel. + /// Moves a user to a voice channel. If null, this user will be disconnected from voice. /// /// /// This user MUST already be in a for this to work. /// - public Optional ChannelId { get; set; } + public Optional ChannelId { get; set; } } } diff --git a/src/Discord.Net.Rest/API/Rest/ModifyGuildMemberParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyGuildMemberParams.cs index 159670afb..a381d6f8f 100644 --- a/src/Discord.Net.Rest/API/Rest/ModifyGuildMemberParams.cs +++ b/src/Discord.Net.Rest/API/Rest/ModifyGuildMemberParams.cs @@ -1,4 +1,4 @@ -#pragma warning disable CS1591 +#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest @@ -15,6 +15,6 @@ namespace Discord.API.Rest [JsonProperty("roles")] public Optional RoleIds { get; set; } [JsonProperty("channel_id")] - public Optional ChannelId { get; set; } + public Optional ChannelId { get; set; } } } diff --git a/src/Discord.Net.Rest/Entities/Users/UserHelper.cs b/src/Discord.Net.Rest/Entities/Users/UserHelper.cs index 3e7493ab5..58e8cd417 100644 --- a/src/Discord.Net.Rest/Entities/Users/UserHelper.cs +++ b/src/Discord.Net.Rest/Entities/Users/UserHelper.cs @@ -1,4 +1,4 @@ -using Discord.API.Rest; +using Discord.API.Rest; using System; using System.Collections.Generic; using System.Threading.Tasks; @@ -39,7 +39,7 @@ namespace Discord.Rest }; if (args.Channel.IsSpecified) - apiArgs.ChannelId = args.Channel.Value.Id; + apiArgs.ChannelId = args.Channel.Value?.Id; else if (args.ChannelId.IsSpecified) apiArgs.ChannelId = args.ChannelId.Value;