Skip to content

Commit

Permalink
Made IVoiceChannel mentionable
Browse files Browse the repository at this point in the history
  • Loading branch information
quinchs committed Sep 24, 2021
1 parent 7e53fe5 commit d0738d6
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/Discord.Net.Core/Discord.Net.Core.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6011,7 +6011,7 @@
<param name="value">The default permission value to set.</param>
<returns>The current builder.</returns>
</member>
<member name="M:Discord.SlashCommandBuilder.AddOption(System.String,Discord.ApplicationCommandOptionType,System.String,System.Boolean,System.Boolean,System.Boolean,System.Collections.Generic.List{Discord.SlashCommandOptionBuilder},Discord.ApplicationCommandOptionChoiceProperties[])">
<member name="M:Discord.SlashCommandBuilder.AddOption(System.String,Discord.ApplicationCommandOptionType,System.String,System.Nullable{System.Boolean},System.Nullable{System.Boolean},System.Boolean,System.Collections.Generic.List{Discord.SlashCommandOptionBuilder},Discord.ApplicationCommandOptionChoiceProperties[])">
<summary>
Adds an option to the current slash command.
</summary>
Expand Down Expand Up @@ -6108,7 +6108,7 @@
</summary>
<returns>The built version of this option.</returns>
</member>
<member name="M:Discord.SlashCommandOptionBuilder.AddOption(System.String,Discord.ApplicationCommandOptionType,System.String,System.Boolean,System.Boolean,System.Collections.Generic.List{Discord.SlashCommandOptionBuilder},Discord.ApplicationCommandOptionChoiceProperties[])">
<member name="M:Discord.SlashCommandOptionBuilder.AddOption(System.String,Discord.ApplicationCommandOptionType,System.String,System.Nullable{System.Boolean},System.Boolean,System.Collections.Generic.List{Discord.SlashCommandOptionBuilder},Discord.ApplicationCommandOptionChoiceProperties[])">
<summary>
Adds an option to the current slash command.
</summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Discord.Net.Core/Entities/Channels/IVoiceChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Discord
/// <summary>
/// Represents a generic voice channel in a guild.
/// </summary>
public interface IVoiceChannel : INestedChannel, IAudioChannel
public interface IVoiceChannel : INestedChannel, IAudioChannel, IMentionable
{
/// <summary>
/// Gets the bit-rate that the clients in this voice channel are requested to use.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public SlashCommandBuilder WithDefaultPermission(bool value)
/// <param name="choices">The choices of this option.</param>
/// <returns>The current builder.</returns>
public SlashCommandBuilder AddOption(string name, ApplicationCommandOptionType type,
string description, bool required = true, bool isDefault = false, bool isAutocomplete = false, List<SlashCommandOptionBuilder> options = null, params ApplicationCommandOptionChoiceProperties[] choices)
string description, bool? required = null, bool? isDefault = null, bool isAutocomplete = false, List<SlashCommandOptionBuilder> options = null, params ApplicationCommandOptionChoiceProperties[] choices)
{
// Make sure the name matches the requirements from discord
Preconditions.NotNullOrEmpty(name, nameof(name));
Expand All @@ -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))
Expand Down Expand Up @@ -339,7 +339,7 @@ public string Description
/// <summary>
/// Gets or sets if the option is required.
/// </summary>
public bool Required { get; set; }
public bool? Required { get; set; } = null;

/// <summary>
/// Gets or sets whether or not this option supports autocomplete.
Expand Down Expand Up @@ -395,7 +395,7 @@ public ApplicationCommandOptionProperties Build()
/// <param name="choices">The choices of this option.</param>
/// <returns>The current builder.</returns>
public SlashCommandOptionBuilder AddOption(string name, ApplicationCommandOptionType type,
string description, bool required = true, bool isDefault = false, List<SlashCommandOptionBuilder> options = null, params ApplicationCommandOptionChoiceProperties[] choices)
string description, bool? required = null, bool isDefault = false, List<SlashCommandOptionBuilder> options = null, params ApplicationCommandOptionChoiceProperties[] choices)
{
// Make sure the name matches the requirements from discord
Preconditions.NotNullOrEmpty(name, nameof(name));
Expand Down
3 changes: 3 additions & 0 deletions src/Discord.Net.Rest/Discord.Net.Rest.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public class RestVoiceChannel : RestGuildChannel, IVoiceChannel, IRestAudioChann
public int? UserLimit { get; private set; }
/// <inheritdoc />
public ulong? CategoryId { get; private set; }

/// <inheritdoc />
public string Mention => MentionUtils.MentionChannel(Id);
internal RestVoiceChannel(BaseDiscordClient discord, IGuild guild, ulong id)
: base(discord, guild, id)
{
Expand Down
3 changes: 3 additions & 0 deletions src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class SocketVoiceChannel : SocketGuildChannel, IVoiceChannel, ISocketAudi
public ICategoryChannel Category
=> CategoryId.HasValue ? Guild.GetChannel(CategoryId.Value) as ICategoryChannel : null;
/// <inheritdoc />
public string Mention => MentionUtils.MentionChannel(Id);
/// <inheritdoc />
public Task SyncPermissionsAsync(RequestOptions options = null)
=> ChannelHelper.SyncPermissionsAsync(this, Discord, options);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d0738d6

Please sign in to comment.