Browse Source

Overload CreateRoleAsync methods

pull/1418/head
Chris Johnston 5 years ago
parent
commit
a0ea784c99
3 changed files with 37 additions and 9 deletions
  1. +15
    -2
      src/Discord.Net.Core/Entities/Guilds/IGuild.cs
  2. +11
    -3
      src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
  3. +11
    -4
      src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs

+ 15
- 2
src/Discord.Net.Core/Entities/Guilds/IGuild.cs View File

@@ -593,13 +593,26 @@ namespace Discord
/// <param name="color">The color of the role.</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="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="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, 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="isMentionable">Whether the role can be mentioned.</param>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns> /// <returns>
/// A task that represents the asynchronous creation operation. The task result contains the newly created /// A task that represents the asynchronous creation operation. The task result contains the newly created
/// role. /// role.
/// </returns> /// </returns>
Task<IRole> 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<IRole> CreateRoleAsync(string name, GuildPermissions? permissions = null, Color? color = null, bool isHoisted = false, bool isMentionable = false, RequestOptions options = null);


/// <summary> /// <summary>
/// Adds a user to this guild. /// Adds a user to this guild.


+ 11
- 3
src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs View File

@@ -530,6 +530,11 @@ namespace Discord.Rest
return null; 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> /// <summary>
/// Creates a new role with the provided name. /// Creates a new role with the provided name.
/// </summary> /// </summary>
@@ -544,7 +549,7 @@ namespace Discord.Rest
/// role. /// role.
/// </returns> /// </returns>
public async Task<RestRole> CreateRoleAsync(string name, GuildPermissions? permissions = default(GuildPermissions?), Color? color = default(Color?), public async Task<RestRole> 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); var role = await GuildHelper.CreateRoleAsync(this, Discord, name, permissions, color, isHoisted, isMentionable, options).ConfigureAwait(false);
_roles = _roles.Add(role.Id, role); _roles = _roles.Add(role.Id, role);
@@ -833,8 +838,11 @@ namespace Discord.Rest
IRole IGuild.GetRole(ulong id) IRole IGuild.GetRole(ulong id)
=> GetRole(id); => GetRole(id);
/// <inheritdoc /> /// <inheritdoc />
async Task<IRole> 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<IRole> IGuild.CreateRoleAsync(string name, GuildPermissions? permissions, Color? color, bool isHoisted, RequestOptions options)
=> 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 /> /// <inheritdoc />
async Task<IGuildUser> IGuild.AddGuildUserAsync(ulong userId, string accessToken, Action<AddGuildUserProperties> func, RequestOptions options) async Task<IGuildUser> IGuild.AddGuildUserAsync(ulong userId, string accessToken, Action<AddGuildUserProperties> func, RequestOptions options)


+ 11
- 4
src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs View File

@@ -679,6 +679,10 @@ namespace Discord.WebSocket
return null; 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> /// <summary>
/// Creates a new role with the provided name. /// Creates a new role with the provided name.
/// </summary> /// </summary>
@@ -686,15 +690,15 @@ namespace Discord.WebSocket
/// <param name="permissions">The guild permission that the role should possess.</param> /// <param name="permissions">The guild permission that the role should possess.</param>
/// <param name="color">The color of the role.</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="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> /// <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> /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception>
/// <returns> /// <returns>
/// A task that represents the asynchronous creation operation. The task result contains the newly created /// A task that represents the asynchronous creation operation. The task result contains the newly created
/// role. /// role.
/// </returns> /// </returns>
public Task<RestRole> CreateRoleAsync(string name, GuildPermissions? permissions = default(GuildPermissions?), Color? color = default(Color?), public Task<RestRole> 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); => GuildHelper.CreateRoleAsync(this, Discord, name, permissions, color, isHoisted, isMentionable, options);
internal SocketRole AddRole(RoleModel model) internal SocketRole AddRole(RoleModel model)
{ {
@@ -1151,8 +1155,11 @@ namespace Discord.WebSocket
IRole IGuild.GetRole(ulong id) IRole IGuild.GetRole(ulong id)
=> GetRole(id); => GetRole(id);
/// <inheritdoc /> /// <inheritdoc />
async Task<IRole> 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<IRole> IGuild.CreateRoleAsync(string name, GuildPermissions? permissions, Color? color, bool isHoisted, RequestOptions options)
=> 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 /> /// <inheritdoc />
Task<IReadOnlyCollection<IGuildUser>> IGuild.GetUsersAsync(CacheMode mode, RequestOptions options) Task<IReadOnlyCollection<IGuildUser>> IGuild.GetUsersAsync(CacheMode mode, RequestOptions options)


Loading…
Cancel
Save