From d0738d67a1c78ed7f291ae9845043067376604be Mon Sep 17 00:00:00 2001 From: quin lynch Date: Fri, 24 Sep 2021 04:39:15 -0300 Subject: [PATCH] Made IVoiceChannel mentionable --- src/Discord.Net.Core/Discord.Net.Core.xml | 4 ++-- src/Discord.Net.Core/Entities/Channels/IVoiceChannel.cs | 2 +- .../Interactions/Slash Commands/SlashCommandBuilder.cs | 8 ++++---- src/Discord.Net.Rest/Discord.Net.Rest.xml | 3 +++ .../Entities/Channels/RestVoiceChannel.cs | 3 ++- src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml | 3 +++ .../Entities/Channels/SocketVoiceChannel.cs | 2 ++ .../MockedEntities/MockedVoiceChannel.cs | 2 +- 8 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/Discord.Net.Core/Discord.Net.Core.xml b/src/Discord.Net.Core/Discord.Net.Core.xml index d8d2d7d165..dc10024a43 100644 --- a/src/Discord.Net.Core/Discord.Net.Core.xml +++ b/src/Discord.Net.Core/Discord.Net.Core.xml @@ -6011,7 +6011,7 @@ The default permission value to set. The current builder. - + Adds an option to the current slash command. @@ -6108,7 +6108,7 @@ The built version of this option. - + Adds an option to the current slash command. diff --git a/src/Discord.Net.Core/Entities/Channels/IVoiceChannel.cs b/src/Discord.Net.Core/Entities/Channels/IVoiceChannel.cs index 9c2d008eea..1d36a41b91 100644 --- a/src/Discord.Net.Core/Entities/Channels/IVoiceChannel.cs +++ b/src/Discord.Net.Core/Entities/Channels/IVoiceChannel.cs @@ -6,7 +6,7 @@ namespace Discord /// /// Represents a generic voice channel in a guild. /// - public interface IVoiceChannel : INestedChannel, IAudioChannel + public interface IVoiceChannel : INestedChannel, IAudioChannel, IMentionable { /// /// Gets the bit-rate that the clients in this voice channel are requested to use. diff --git a/src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandBuilder.cs index 1a152feb4e..9581015d0c 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandBuilder.cs @@ -165,7 +165,7 @@ public SlashCommandBuilder WithDefaultPermission(bool value) /// The choices of this option. /// The current builder. public SlashCommandBuilder AddOption(string name, ApplicationCommandOptionType type, - string description, bool required = true, bool isDefault = false, bool isAutocomplete = false, List options = null, params ApplicationCommandOptionChoiceProperties[] choices) + string description, bool? required = null, bool? isDefault = null, bool isAutocomplete = false, List options = null, params ApplicationCommandOptionChoiceProperties[] choices) { // Make sure the name matches the requirements from discord Preconditions.NotNullOrEmpty(name, nameof(name)); @@ -183,7 +183,7 @@ public SlashCommandBuilder AddOption(string name, ApplicationCommandOptionType t Preconditions.AtMost(description.Length, MaxDescriptionLength, nameof(description)); // make sure theres only one option with default set to true - if (isDefault) + if (isDefault.HasValue && isDefault.Value) { if (this.Options != null) if (this.Options.Any(x => x.Default.HasValue && x.Default.Value)) @@ -339,7 +339,7 @@ public string Description /// /// Gets or sets if the option is required. /// - public bool Required { get; set; } + public bool? Required { get; set; } = null; /// /// Gets or sets whether or not this option supports autocomplete. @@ -395,7 +395,7 @@ public ApplicationCommandOptionProperties Build() /// The choices of this option. /// The current builder. public SlashCommandOptionBuilder AddOption(string name, ApplicationCommandOptionType type, - string description, bool required = true, bool isDefault = false, List options = null, params ApplicationCommandOptionChoiceProperties[] choices) + string description, bool? required = null, bool isDefault = false, List options = null, params ApplicationCommandOptionChoiceProperties[] choices) { // Make sure the name matches the requirements from discord Preconditions.NotNullOrEmpty(name, nameof(name)); diff --git a/src/Discord.Net.Rest/Discord.Net.Rest.xml b/src/Discord.Net.Rest/Discord.Net.Rest.xml index 6e6b76d217..ec25845809 100644 --- a/src/Discord.Net.Rest/Discord.Net.Rest.xml +++ b/src/Discord.Net.Rest/Discord.Net.Rest.xml @@ -2803,6 +2803,9 @@ + + + diff --git a/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs index d1d567e272..b8ee8fc93d 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs @@ -21,7 +21,8 @@ public class RestVoiceChannel : RestGuildChannel, IVoiceChannel, IRestAudioChann public int? UserLimit { get; private set; } /// public ulong? CategoryId { get; private set; } - + /// + public string Mention => MentionUtils.MentionChannel(Id); internal RestVoiceChannel(BaseDiscordClient discord, IGuild guild, ulong id) : base(discord, guild, id) { diff --git a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml index c089062904..10c5d5e8da 100644 --- a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml +++ b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml @@ -2802,6 +2802,9 @@ A category channel representing the parent of this channel; null if none is set. + + + diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketVoiceChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketVoiceChannel.cs index f1d61b9b3a..9798272b37 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketVoiceChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketVoiceChannel.cs @@ -32,6 +32,8 @@ public class SocketVoiceChannel : SocketGuildChannel, IVoiceChannel, ISocketAudi public ICategoryChannel Category => CategoryId.HasValue ? Guild.GetChannel(CategoryId.Value) as ICategoryChannel : null; /// + public string Mention => MentionUtils.MentionChannel(Id); + /// public Task SyncPermissionsAsync(RequestOptions options = null) => ChannelHelper.SyncPermissionsAsync(this, Discord, options); diff --git a/test/Discord.Net.Tests.Unit/MockedEntities/MockedVoiceChannel.cs b/test/Discord.Net.Tests.Unit/MockedEntities/MockedVoiceChannel.cs index 7c3d00fdd1..159bfb034a 100644 --- a/test/Discord.Net.Tests.Unit/MockedEntities/MockedVoiceChannel.cs +++ b/test/Discord.Net.Tests.Unit/MockedEntities/MockedVoiceChannel.cs @@ -25,7 +25,7 @@ internal sealed class MockedVoiceChannel : IVoiceChannel public string Name => throw new NotImplementedException(); public DateTimeOffset CreatedAt => throw new NotImplementedException(); - + public string Mention => throw new NotImplementedException(); public ulong Id => throw new NotImplementedException(); public Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options = null)