* Fix #1335 Add isMentionable parameter to CreateRoleAsync in non-breaking manner This PR adds the isMentionable parameter to the CreateRoleAsync method in a way that prevents it from being interface-breaking. This has been done by adding it as an optional parameter at the end of publicly-exposed methods. This parameter determines if the newly created role can be mentioned as it is created. * Overload CreateRoleAsync methodstags/2.2.0
| @@ -598,6 +598,21 @@ namespace Discord | |||
| /// role. | |||
| /// </returns> | |||
| Task<IRole> CreateRoleAsync(string name, GuildPermissions? permissions = null, Color? color = null, bool isHoisted = false, RequestOptions options = null); | |||
| // TODO remove CreateRoleAsync overload that does not have isMentionable when breaking change is acceptable | |||
| /// <summary> | |||
| /// Creates a new role with the provided name. | |||
| /// </summary> | |||
| /// <param name="name">The new name for the role.</param> | |||
| /// <param name="permissions">The guild permission that the role should possess.</param> | |||
| /// <param name="color">The color of the role.</param> | |||
| /// <param name="isHoisted">Whether the role is separated from others on the sidebar.</param> | |||
| /// <param name="isMentionable">Whether the role can be mentioned.</param> | |||
| /// <param name="options">The options to be used when sending the request.</param> | |||
| /// <returns> | |||
| /// A task that represents the asynchronous creation operation. The task result contains the newly created | |||
| /// role. | |||
| /// </returns> | |||
| Task<IRole> CreateRoleAsync(string name, GuildPermissions? permissions = null, Color? color = null, bool isHoisted = false, bool isMentionable = false, RequestOptions options = null); | |||
| /// <summary> | |||
| /// Adds a user to this guild. | |||
| @@ -257,7 +257,7 @@ namespace Discord.Rest | |||
| //Roles | |||
| /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception> | |||
| public static async Task<RestRole> CreateRoleAsync(IGuild guild, BaseDiscordClient client, | |||
| string name, GuildPermissions? permissions, Color? color, bool isHoisted, RequestOptions options) | |||
| string name, GuildPermissions? permissions, Color? color, bool isHoisted, bool isMentionable, RequestOptions options) | |||
| { | |||
| if (name == null) throw new ArgumentNullException(paramName: nameof(name)); | |||
| @@ -270,6 +270,7 @@ namespace Discord.Rest | |||
| x.Permissions = (permissions ?? role.Permissions); | |||
| x.Color = (color ?? Color.Default); | |||
| x.Hoist = isHoisted; | |||
| x.Mentionable = isMentionable; | |||
| }, options).ConfigureAwait(false); | |||
| return role; | |||
| @@ -530,6 +530,11 @@ namespace Discord.Rest | |||
| return null; | |||
| } | |||
| /// <inheritdoc /> | |||
| public Task<RestRole> CreateRoleAsync(string name, GuildPermissions? permissions = default(GuildPermissions?), Color? color = default(Color?), | |||
| bool isHoisted = false, RequestOptions options = null) | |||
| => CreateRoleAsync(name, permissions, color, isHoisted, false, options); | |||
| /// <summary> | |||
| /// Creates a new role with the provided name. | |||
| /// </summary> | |||
| @@ -538,14 +543,15 @@ namespace Discord.Rest | |||
| /// <param name="color">The color of the role.</param> | |||
| /// <param name="isHoisted">Whether the role is separated from others on the sidebar.</param> | |||
| /// <param name="options">The options to be used when sending the request.</param> | |||
| /// <param name="isMentionable">Whether the role can be mentioned.</param> | |||
| /// <returns> | |||
| /// A task that represents the asynchronous creation operation. The task result contains the newly created | |||
| /// role. | |||
| /// </returns> | |||
| public async Task<RestRole> CreateRoleAsync(string name, GuildPermissions? permissions = default(GuildPermissions?), Color? color = default(Color?), | |||
| bool isHoisted = false, RequestOptions options = null) | |||
| bool isHoisted = false, bool isMentionable = false, RequestOptions options = null) | |||
| { | |||
| var role = await GuildHelper.CreateRoleAsync(this, Discord, name, permissions, color, isHoisted, options).ConfigureAwait(false); | |||
| var role = await GuildHelper.CreateRoleAsync(this, Discord, name, permissions, color, isHoisted, isMentionable, options).ConfigureAwait(false); | |||
| _roles = _roles.Add(role.Id, role); | |||
| return role; | |||
| } | |||
| @@ -833,7 +839,10 @@ namespace Discord.Rest | |||
| => GetRole(id); | |||
| /// <inheritdoc /> | |||
| async Task<IRole> IGuild.CreateRoleAsync(string name, GuildPermissions? permissions, Color? color, bool isHoisted, RequestOptions options) | |||
| => await CreateRoleAsync(name, permissions, color, isHoisted, options).ConfigureAwait(false); | |||
| => await CreateRoleAsync(name, permissions, color, isHoisted, false, options).ConfigureAwait(false); | |||
| /// <inheritdoc /> | |||
| async Task<IRole> IGuild.CreateRoleAsync(string name, GuildPermissions? permissions, Color? color, bool isHoisted, bool isMentionable, RequestOptions options) | |||
| => await CreateRoleAsync(name, permissions, color, isHoisted, isMentionable, options).ConfigureAwait(false); | |||
| /// <inheritdoc /> | |||
| async Task<IGuildUser> IGuild.AddGuildUserAsync(ulong userId, string accessToken, Action<AddGuildUserProperties> func, RequestOptions options) | |||
| @@ -679,6 +679,10 @@ namespace Discord.WebSocket | |||
| return null; | |||
| } | |||
| /// <inheritdoc /> | |||
| public Task<RestRole> CreateRoleAsync(string name, GuildPermissions? permissions = default(GuildPermissions?), Color? color = default(Color?), | |||
| bool isHoisted = false, RequestOptions options = null) | |||
| => GuildHelper.CreateRoleAsync(this, Discord, name, permissions, color, isHoisted, false, options); | |||
| /// <summary> | |||
| /// Creates a new role with the provided name. | |||
| /// </summary> | |||
| @@ -686,6 +690,7 @@ namespace Discord.WebSocket | |||
| /// <param name="permissions">The guild permission that the role should possess.</param> | |||
| /// <param name="color">The color of the role.</param> | |||
| /// <param name="isHoisted">Whether the role is separated from others on the sidebar.</param> | |||
| /// <param name="isMentionable">Whether the role can be mentioned.</param> | |||
| /// <param name="options">The options to be used when sending the request.</param> | |||
| /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception> | |||
| /// <returns> | |||
| @@ -693,8 +698,8 @@ namespace Discord.WebSocket | |||
| /// role. | |||
| /// </returns> | |||
| public Task<RestRole> CreateRoleAsync(string name, GuildPermissions? permissions = default(GuildPermissions?), Color? color = default(Color?), | |||
| bool isHoisted = false, RequestOptions options = null) | |||
| => GuildHelper.CreateRoleAsync(this, Discord, name, permissions, color, isHoisted, options); | |||
| bool isHoisted = false, bool isMentionable = false, RequestOptions options = null) | |||
| => GuildHelper.CreateRoleAsync(this, Discord, name, permissions, color, isHoisted, isMentionable, options); | |||
| internal SocketRole AddRole(RoleModel model) | |||
| { | |||
| var role = SocketRole.Create(this, Discord.State, model); | |||
| @@ -1151,7 +1156,10 @@ namespace Discord.WebSocket | |||
| => GetRole(id); | |||
| /// <inheritdoc /> | |||
| async Task<IRole> IGuild.CreateRoleAsync(string name, GuildPermissions? permissions, Color? color, bool isHoisted, RequestOptions options) | |||
| => await CreateRoleAsync(name, permissions, color, isHoisted, options).ConfigureAwait(false); | |||
| => await CreateRoleAsync(name, permissions, color, isHoisted, false, options).ConfigureAwait(false); | |||
| /// <inheritdoc /> | |||
| async Task<IRole> IGuild.CreateRoleAsync(string name, GuildPermissions? permissions, Color? color, bool isHoisted, bool isMentionable, RequestOptions options) | |||
| => await CreateRoleAsync(name, permissions, color, isHoisted, isMentionable, options).ConfigureAwait(false); | |||
| /// <inheritdoc /> | |||
| Task<IReadOnlyCollection<IGuildUser>> IGuild.GetUsersAsync(CacheMode mode, RequestOptions options) | |||