public async Task <Webhook> CreateWebhookAsync(CreateWebhookParams @params, CancellationToken?token = default(CancellationToken?)) { using (var response = await Post(BuildEndpoint($"projects/{@params.ProjectIdOrKey}/webhooks"), @params, token: token)) using (var content = response.Content) { return(await Factory.CreateWebhookAsync(response)); } }
//Webhooks public static async Task<RestWebhook> CreateWebhookAsync(ITextChannel channel, BaseDiscordClient client, string name, Stream avatar, RequestOptions options) { var args = new CreateWebhookParams { Name = name }; if (avatar != null) args.Avatar = new API.Image(avatar); var model = await client.ApiClient.CreateWebhookAsync(channel.Id, args, options).ConfigureAwait(false); return RestWebhook.Create(client, channel, model); }
public async Task <IActionResult> CreateWebhookAsync(Snowflake channelId, [FromBody] CreateWebhookParams args) { args.Validate(); return(Ok(new Webhook { ChannelId = channelId, Avatar = args.Avatar.ToNullable(), Name = args.Name })); }