From a0ea784c996287f112bef4178acbf6fce514141a Mon Sep 17 00:00:00 2001 From: Chris Johnston Date: Thu, 14 Nov 2019 18:31:41 -0800 Subject: [PATCH] Overload CreateRoleAsync methods --- src/Discord.Net.Core/Entities/Guilds/IGuild.cs | 17 +++++++++++++++-- .../Entities/Guilds/RestGuild.cs | 14 +++++++++++--- .../Entities/Guilds/SocketGuild.cs | 15 +++++++++++---- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs index bb8088b5b..a18e91b69 100644 --- a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs +++ b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs @@ -593,13 +593,26 @@ namespace Discord /// The color of the role. /// Whether the role is separated from others on the sidebar. /// The options to be used when sending the request. + /// + /// A task that represents the asynchronous creation operation. The task result contains the newly created + /// role. + /// + Task 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 + /// + /// Creates a new role with the provided name. + /// + /// The new name for the role. + /// The guild permission that the role should possess. + /// The color of the role. + /// Whether the role is separated from others on the sidebar. /// Whether the role can be mentioned. + /// The options to be used when sending the request. /// /// A task that represents the asynchronous creation operation. The task result contains the newly created /// role. /// - Task CreateRoleAsync(string name, GuildPermissions? permissions = null, Color? color = null, bool isHoisted = false, RequestOptions options = null, bool isMentionable = false); - // TODO Chris-Johnston: 3.x breaking interface change: re-order isMentionable parameter + Task CreateRoleAsync(string name, GuildPermissions? permissions = null, Color? color = null, bool isHoisted = false, bool isMentionable = false, RequestOptions options = null); /// /// Adds a user to this guild. diff --git a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs index 48a532e13..900f5045e 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs @@ -530,6 +530,11 @@ namespace Discord.Rest return null; } + /// + public Task CreateRoleAsync(string name, GuildPermissions? permissions = default(GuildPermissions?), Color? color = default(Color?), + bool isHoisted = false, RequestOptions options = null) + => CreateRoleAsync(name, permissions, color, isHoisted, false, options); + /// /// Creates a new role with the provided name. /// @@ -544,7 +549,7 @@ namespace Discord.Rest /// role. /// public async Task CreateRoleAsync(string name, GuildPermissions? permissions = default(GuildPermissions?), Color? color = default(Color?), - bool isHoisted = false, RequestOptions options = null, bool isMentionable = false) + bool isHoisted = false, bool isMentionable = false, RequestOptions options = null) { var role = await GuildHelper.CreateRoleAsync(this, Discord, name, permissions, color, isHoisted, isMentionable, options).ConfigureAwait(false); _roles = _roles.Add(role.Id, role); @@ -833,8 +838,11 @@ namespace Discord.Rest IRole IGuild.GetRole(ulong id) => GetRole(id); /// - async Task IGuild.CreateRoleAsync(string name, GuildPermissions? permissions, Color? color, bool isHoisted, RequestOptions options, bool isMentionable) - => await CreateRoleAsync(name, permissions, color, isHoisted, options, isMentionable).ConfigureAwait(false); + async Task IGuild.CreateRoleAsync(string name, GuildPermissions? permissions, Color? color, bool isHoisted, RequestOptions options) + => await CreateRoleAsync(name, permissions, color, isHoisted, false, options).ConfigureAwait(false); + /// + async Task IGuild.CreateRoleAsync(string name, GuildPermissions? permissions, Color? color, bool isHoisted, bool isMentionable, RequestOptions options) + => await CreateRoleAsync(name, permissions, color, isHoisted, isMentionable, options).ConfigureAwait(false); /// async Task IGuild.AddGuildUserAsync(ulong userId, string accessToken, Action func, RequestOptions options) diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs index cf44e3506..da9a316eb 100644 --- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs +++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs @@ -679,6 +679,10 @@ namespace Discord.WebSocket return null; } + /// + public Task 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); /// /// Creates a new role with the provided name. /// @@ -686,15 +690,15 @@ namespace Discord.WebSocket /// The guild permission that the role should possess. /// The color of the role. /// Whether the role is separated from others on the sidebar. - /// The options to be used when sending the request. /// Whether the role can be mentioned. + /// The options to be used when sending the request. /// is null. /// /// A task that represents the asynchronous creation operation. The task result contains the newly created /// role. /// public Task CreateRoleAsync(string name, GuildPermissions? permissions = default(GuildPermissions?), Color? color = default(Color?), - bool isHoisted = false, RequestOptions options = null, bool isMentionable = false) + bool isHoisted = false, bool isMentionable = false, RequestOptions options = null) => GuildHelper.CreateRoleAsync(this, Discord, name, permissions, color, isHoisted, isMentionable, options); internal SocketRole AddRole(RoleModel model) { @@ -1151,8 +1155,11 @@ namespace Discord.WebSocket IRole IGuild.GetRole(ulong id) => GetRole(id); /// - async Task IGuild.CreateRoleAsync(string name, GuildPermissions? permissions, Color? color, bool isHoisted, RequestOptions options, bool isMentionable) - => await CreateRoleAsync(name, permissions, color, isHoisted, options, isMentionable).ConfigureAwait(false); + async Task IGuild.CreateRoleAsync(string name, GuildPermissions? permissions, Color? color, bool isHoisted, RequestOptions options) + => await CreateRoleAsync(name, permissions, color, isHoisted, false, options).ConfigureAwait(false); + /// + async Task IGuild.CreateRoleAsync(string name, GuildPermissions? permissions, Color? color, bool isHoisted, bool isMentionable, RequestOptions options) + => await CreateRoleAsync(name, permissions, color, isHoisted, isMentionable, options).ConfigureAwait(false); /// Task> IGuild.GetUsersAsync(CacheMode mode, RequestOptions options)