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
webhook
IWebhook
DiscordWebhookClient(IWebhook, DiscordRestConfig)
Creates a new Webhook Discord client.
public DiscordWebhookClient(IWebhook webhook, DiscordRestConfig config)
Parameters
webhook
IWebhookconfig
DiscordRestConfig
DiscordWebhookClient(string)
Creates a new Webhook Discord client.
public DiscordWebhookClient(string webhookUrl)
Parameters
webhookUrl
string
DiscordWebhookClient(string, DiscordRestConfig)
Creates a new Webhook Discord client.
public DiscordWebhookClient(string webhookUrl, DiscordRestConfig config)
Parameters
webhookUrl
stringThe url of the webhook.
config
DiscordRestConfigThe configuration options to use for this client.
Exceptions
- ArgumentException
Thrown if the
webhookUrl
is an invalid format.- ArgumentNullException
Thrown if the
webhookUrl
is 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
webhookId
ulongwebhookToken
stringconfig
DiscordRestConfig
Methods
DeleteMessageAsync(ulong, RequestOptions, ulong?)
Deletes a message posted using this webhook.
public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null, ulong? threadId = null)
Parameters
messageId
ulongID of the deleted message.
options
RequestOptionsThe options to be used when sending the request.
threadId
ulong?
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
options
RequestOptions
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
messageId
ulongID of the modified message.
func
Action<WebhookMessageProperties>A delegate containing the properties to modify the message with.
options
RequestOptionsThe options to be used when sending the request.
threadId
ulong?
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
func
Action<WebhookProperties>options
RequestOptions
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
attachment
FileAttachmenttext
stringisTTS
boolembeds
IEnumerable<Embed>username
stringavatarUrl
stringoptions
RequestOptionsallowedMentions
AllowedMentionscomponents
MessageComponentflags
MessageFlagsthreadId
ulong?threadName
stringappliedTags
ulong[]poll
PollProperties
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
stream
Streamfilename
stringtext
stringisTTS
boolembeds
IEnumerable<Embed>username
stringavatarUrl
stringoptions
RequestOptionsisSpoiler
boolallowedMentions
AllowedMentionscomponents
MessageComponentflags
MessageFlagsthreadId
ulong?threadName
stringappliedTags
ulong[]poll
PollProperties
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
filePath
stringtext
stringisTTS
boolembeds
IEnumerable<Embed>username
stringavatarUrl
stringoptions
RequestOptionsisSpoiler
boolallowedMentions
AllowedMentionscomponents
MessageComponentflags
MessageFlagsthreadId
ulong?threadName
stringappliedTags
ulong[]poll
PollProperties
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
attachments
IEnumerable<FileAttachment>text
stringisTTS
boolembeds
IEnumerable<Embed>username
stringavatarUrl
stringoptions
RequestOptionsallowedMentions
AllowedMentionscomponents
MessageComponentflags
MessageFlagsthreadId
ulong?threadName
stringappliedTags
ulong[]poll
PollProperties
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
text
stringisTTS
boolembeds
IEnumerable<Embed>username
stringavatarUrl
stringoptions
RequestOptionsallowedMentions
AllowedMentionscomponents
MessageComponentflags
MessageFlagsthreadId
ulong?threadName
stringappliedTags
ulong[]poll
PollProperties
Returns
Events
Log
public event Func<LogMessage, Task> Log