/// <summary> /// Creates a new Webhook Discord client. /// </summary> /// <param name="webhookUrl">The url of the webhook.</param> /// <param name="config">The configuration options to use for this client.</param> /// <exception cref="ArgumentException">Thrown if the <paramref name="webhookUrl"/> is an invalid format.</exception> /// <exception cref="ArgumentNullException">Thrown if the <paramref name="webhookUrl"/> is null or whitespace.</exception> public DiscordWebhookClient(string webhookUrl, DiscordRestConfig config) : this(config) { string token; ParseWebhookUrl(webhookUrl, out _webhookId, out token); ApiClient.LoginAsync(TokenType.Webhook, token).GetAwaiter().GetResult(); Webhook = WebhookClientHelper.GetWebhookAsync(this, _webhookId).GetAwaiter().GetResult(); }
/// <summary> Creates a new Webhook Discord client. </summary> public DiscordWebhookClient(ulong webhookId, string webhookToken, DiscordRestConfig config) : this(config) { _webhookId = webhookId; ApiClient.LoginAsync(TokenType.Webhook, webhookToken).GetAwaiter().GetResult(); Webhook = WebhookClientHelper.GetWebhookAsync(this, webhookId).GetAwaiter().GetResult(); }
public Task DeleteAsync(RequestOptions options = null) => WebhookClientHelper.DeleteAsync(_client, options);
public async Task ModifyAsync(Action <WebhookProperties> func, RequestOptions options = null) { var model = await WebhookClientHelper.ModifyAsync(_client, func, options).ConfigureAwait(false); Update(model); }
/// <summary> Sends a message to the channel for this webhook with an attachment. </summary> /// <returns> Returns the ID of the created message. </returns> public Task <ulong> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, IEnumerable <Embed> embeds = null, string username = null, string avatarUrl = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null) => WebhookClientHelper.SendFileAsync(this, stream, filename, text, isTTS, embeds, username, avatarUrl, allowedMentions, options, isSpoiler);
/// <summary> Sends a message to the channel for this webhook with an attachment. </summary> /// <returns> Returns the ID of the created message. </returns> public Task <ulong> SendFileAsync(string filePath, string text, bool isTTS = false, IEnumerable <Embed> embeds = null, string username = null, string avatarUrl = null, RequestOptions options = null, bool isSpoiler = false) => WebhookClientHelper.SendFileAsync(this, filePath, text, isTTS, embeds, username, avatarUrl, options, isSpoiler);
/// <summary> Sends a message to the channel for this webhook. </summary> /// <returns> Returns the ID of the created message. </returns> public Task <ulong> SendMessageAsync(string text = null, bool isTTS = false, IEnumerable <Embed> embeds = null, string username = null, string avatarUrl = null, RequestOptions options = null, AllowedMentions allowedMentions = null) => WebhookClientHelper.SendMessageAsync(this, text, isTTS, embeds, username, avatarUrl, allowedMentions, options);
/// <summary> /// Deletes a message posted using this webhook. /// </summary> /// <remarks> /// This method can only delete messages that were sent using the same webhook. /// </remarks> /// <param name="messageId">ID of the deleted message.</param> /// <param name="options">The options to be used when sending the request.</param> /// <returns> /// A task that represents the asynchronous deletion operation. /// </returns> public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) => WebhookClientHelper.DeleteMessageAsync(this, messageId, options);
/// <summary> /// Modifies a message posted using this webhook. /// </summary> /// <remarks> /// This method can only modify messages that were sent using the same webhook. /// </remarks> /// <param name="messageId">ID of the modified message.</param> /// <param name="func">A delegate containing the properties to modify the message with.</param> /// <param name="options">The options to be used when sending the request.</param> /// <returns> /// A task that represents the asynchronous modification operation. /// </returns> public Task ModifyMessageAsync(ulong messageId, Action <WebhookMessageProperties> func, RequestOptions options = null) => WebhookClientHelper.ModifyMessageAsync(this, messageId, func, options);
/// <summary> Sends a message to the channel for this webhook with an attachment. </summary> /// <returns> Returns the ID of the created message. </returns> public Task <ulong> SendFilesAsync(IEnumerable <FileAttachment> attachments, string text, bool isTTS = false, IEnumerable <Embed> embeds = null, string username = null, string avatarUrl = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageComponent components = null, MessageFlags flags = MessageFlags.None) => WebhookClientHelper.SendFilesAsync(this, attachments, text, isTTS, embeds, username, avatarUrl, allowedMentions, components, options, flags);
/// <summary> Sends a message to the channel for this webhook with an attachment. </summary> /// <returns> Returns the ID of the created message. </returns> public Task <ulong> SendFileAsync(string filePath, string text, bool isTTS = false, IEnumerable <Embed> embeds = null, string username = null, string avatarUrl = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageComponent components = null) => WebhookClientHelper.SendFileAsync(this, filePath, text, isTTS, embeds, username, avatarUrl, allowedMentions, options, isSpoiler, components);
/// <summary> Sends a message to the channel for this webhook with an attachment. </summary> /// <returns> Returns the ID of the created message. </returns> public Task <ulong> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, IEnumerable <Embed> embeds = null, string username = null, string avatarUrl = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageComponent components = null, MessageFlags flags = MessageFlags.None, ulong?threadId = null) => WebhookClientHelper.SendFileAsync(this, stream, filename, text, isTTS, embeds, username, avatarUrl, allowedMentions, options, isSpoiler, components, flags, threadId);