Class DiscordWebhookClient
A client responsible for connecting as a Webhook.
public class DiscordWebhookClient : IDisposable
- Inheritance
-
DiscordWebhookClient
- Implements
- Inherited Members
Constructors
DiscordWebhookClient(IWebhook)
Creates a new Webhook Discord client.
public DiscordWebhookClient(IWebhook webhook)
Parameters
webhookIWebhook
DiscordWebhookClient(IWebhook, DiscordRestConfig)
Creates a new Webhook Discord client.
public DiscordWebhookClient(IWebhook webhook, DiscordRestConfig config)
Parameters
webhookIWebhookconfigDiscordRestConfig
DiscordWebhookClient(string)
Creates a new Webhook Discord client.
public DiscordWebhookClient(string webhookUrl)
Parameters
webhookUrlstring
DiscordWebhookClient(string, DiscordRestConfig)
Creates a new Webhook Discord client.
public DiscordWebhookClient(string webhookUrl, DiscordRestConfig config)
Parameters
webhookUrlstringThe url of the webhook.
configDiscordRestConfigThe configuration options to use for this client.
Exceptions
- ArgumentException
Thrown if the
webhookUrlis an invalid format.- ArgumentNullException
Thrown if the
webhookUrlis null or whitespace.
DiscordWebhookClient(ulong, string)
Creates a new Webhook Discord client.
public DiscordWebhookClient(ulong webhookId, string webhookToken)
Parameters
DiscordWebhookClient(ulong, string, DiscordRestConfig)
Creates a new Webhook Discord client.
public DiscordWebhookClient(ulong webhookId, string webhookToken, DiscordRestConfig config)
Parameters
webhookIdulongwebhookTokenstringconfigDiscordRestConfig
Methods
DeleteMessageAsync(ulong, RequestOptions, ulong?)
Deletes a message posted using this webhook.
public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null, ulong? threadId = null)
Parameters
messageIdulongID of the deleted message.
optionsRequestOptionsThe options to be used when sending the request.
threadIdulong?
Returns
- Task
A task that represents the asynchronous deletion operation.
Remarks
This method can only delete messages that were sent using the same webhook.
DeleteWebhookAsync(RequestOptions)
Deletes this webhook from Discord and disposes the client.
public Task DeleteWebhookAsync(RequestOptions options = null)
Parameters
optionsRequestOptions
Returns
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
ModifyMessageAsync(ulong, Action<WebhookMessageProperties>, RequestOptions, ulong?)
Modifies a message posted using this webhook.
public Task ModifyMessageAsync(ulong messageId, Action<WebhookMessageProperties> func, RequestOptions options = null, ulong? threadId = null)
Parameters
messageIdulongID of the modified message.
funcAction<WebhookMessageProperties>A delegate containing the properties to modify the message with.
optionsRequestOptionsThe options to be used when sending the request.
threadIdulong?
Returns
- Task
A task that represents the asynchronous modification operation.
Remarks
This method can only modify messages that were sent using the same webhook.
ModifyWebhookAsync(Action<WebhookProperties>, RequestOptions)
Modifies the properties of this webhook.
public Task ModifyWebhookAsync(Action<WebhookProperties> func, RequestOptions options = null)
Parameters
funcAction<WebhookProperties>optionsRequestOptions
Returns
SendFileAsync(FileAttachment, string, bool, IEnumerable<Embed>, string, string, RequestOptions, AllowedMentions, MessageComponent, MessageFlags, ulong?, string, ulong[], PollProperties)
Sends a message to the channel for this webhook with an attachment.
public Task<ulong> SendFileAsync(FileAttachment attachment, 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, ulong? threadId = null, string threadName = null, ulong[] appliedTags = null, PollProperties poll = null)
Parameters
attachmentFileAttachmenttextstringisTTSboolembedsIEnumerable<Embed>usernamestringavatarUrlstringoptionsRequestOptionsallowedMentionsAllowedMentionscomponentsMessageComponentflagsMessageFlagsthreadIdulong?threadNamestringappliedTagsulong[]pollPollProperties
Returns
SendFileAsync(Stream, string, string, bool, IEnumerable<Embed>, string, string, RequestOptions, bool, AllowedMentions, MessageComponent, MessageFlags, ulong?, string, ulong[], PollProperties)
Sends a message to the channel for this webhook with an attachment.
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, string threadName = null, ulong[] appliedTags = null, PollProperties poll = null)
Parameters
streamStreamfilenamestringtextstringisTTSboolembedsIEnumerable<Embed>usernamestringavatarUrlstringoptionsRequestOptionsisSpoilerboolallowedMentionsAllowedMentionscomponentsMessageComponentflagsMessageFlagsthreadIdulong?threadNamestringappliedTagsulong[]pollPollProperties
Returns
SendFileAsync(string, string, bool, IEnumerable<Embed>, string, string, RequestOptions, bool, AllowedMentions, MessageComponent, MessageFlags, ulong?, string, ulong[], PollProperties)
Sends a message to the channel for this webhook with an attachment.
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, MessageFlags flags = MessageFlags.None, ulong? threadId = null, string threadName = null, ulong[] appliedTags = null, PollProperties poll = null)
Parameters
filePathstringtextstringisTTSboolembedsIEnumerable<Embed>usernamestringavatarUrlstringoptionsRequestOptionsisSpoilerboolallowedMentionsAllowedMentionscomponentsMessageComponentflagsMessageFlagsthreadIdulong?threadNamestringappliedTagsulong[]pollPollProperties
Returns
SendFilesAsync(IEnumerable<FileAttachment>, string, bool, IEnumerable<Embed>, string, string, RequestOptions, AllowedMentions, MessageComponent, MessageFlags, ulong?, string, ulong[], PollProperties)
Sends a message to the channel for this webhook with an attachment.
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, ulong? threadId = null, string threadName = null, ulong[] appliedTags = null, PollProperties poll = null)
Parameters
attachmentsIEnumerable<FileAttachment>textstringisTTSboolembedsIEnumerable<Embed>usernamestringavatarUrlstringoptionsRequestOptionsallowedMentionsAllowedMentionscomponentsMessageComponentflagsMessageFlagsthreadIdulong?threadNamestringappliedTagsulong[]pollPollProperties
Returns
SendMessageAsync(string, bool, IEnumerable<Embed>, string, string, RequestOptions, AllowedMentions, MessageComponent, MessageFlags, ulong?, string, ulong[], PollProperties)
Sends a message to the channel for this webhook.
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, MessageComponent components = null, MessageFlags flags = MessageFlags.None, ulong? threadId = null, string threadName = null, ulong[] appliedTags = null, PollProperties poll = null)
Parameters
textstringisTTSboolembedsIEnumerable<Embed>usernamestringavatarUrlstringoptionsRequestOptionsallowedMentionsAllowedMentionscomponentsMessageComponentflagsMessageFlagsthreadIdulong?threadNamestringappliedTagsulong[]pollPollProperties
Returns
Events
Log
public event Func<LogMessage, Task> Log