public async Task <DiscordRolePacket> CreateGuildRoleAsync(ulong guildId, CreateRoleArgs args) { return((await RatelimitHelper.ProcessRateLimitedAsync( $"guilds:{guildId}", cache, async() => { return await RestClient.PostAsync <DiscordRolePacket>( $"/guilds/{guildId}/roles", JsonConvert.SerializeObject(args) ?? "" ); })).Data); }
/// <inheritdoc/> public async Task <DiscordRolePacket> CreateGuildRoleAsync( ulong guildId, CreateRoleArgs args) { var response = await httpClient.PostAsync( DiscordApiRoutes.GuildRoles(guildId), JsonSerializer.Serialize(args, options) ?? "") .ConfigureAwait(false); HandleErrors(response, options); return(JsonSerializer.Deserialize <DiscordRolePacket>(response.Body, options)); }
/// <summary> /// Creates a new role in the guild specified. /// </summary> /// <param name="guildId">The guild in which you want to create a role.</param> /// <param name="args">The properties of the role.</param> /// <returns>The role you've created, if successful</returns> public async ValueTask <DiscordRolePacket> CreateGuildRoleAsync( ulong guildId, CreateRoleArgs args) { var response = await RestClient.PostJsonAsync( DiscordApiRoutes.GuildRoles(guildId), args) .ConfigureAwait(false); HandleErrors(response); return(JsonHelper.Deserialize <DiscordRolePacket>(response.Body)); }
/// <inheritdoc /> public async Task <IDiscordRole> CreateRoleAsync(CreateRoleArgs roleParams = null) => await client.CreateRoleAsync(Id, roleParams);
public async Task <IDiscordRole> CreateRoleAsync(ulong guildId, CreateRoleArgs args = null) => new DiscordRole( await _apiClient.CreateGuildRoleAsync(guildId, args), this );
public ValueTask <IDiscordRole> CreateRoleAsync(CreateRoleArgs roleParams = null) { return(_client.CreateRoleAsync(Id, roleParams)); }