Table of Contents

Class DiscordWebhookClient

Namespace
Discord.Webhook
Assembly
Discord.Net.Webhook.dll

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 IWebhook
config 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 string

The url of the webhook.

config DiscordRestConfig

The 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

webhookId ulong
webhookToken string

DiscordWebhookClient(ulong, string, DiscordRestConfig)

Creates a new Webhook Discord client.

public DiscordWebhookClient(ulong webhookId, string webhookToken, DiscordRestConfig config)

Parameters

webhookId ulong
webhookToken string
config 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 ulong

ID of the deleted message.

options RequestOptions

The 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

Task

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 ulong

ID of the modified message.

func Action<WebhookMessageProperties>

A delegate containing the properties to modify the message with.

options RequestOptions

The 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

Task

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 FileAttachment
text string
isTTS bool
embeds IEnumerable<Embed>
username string
avatarUrl string
options RequestOptions
allowedMentions AllowedMentions
components MessageComponent
flags MessageFlags
threadId ulong?
threadName string
appliedTags ulong[]
poll PollProperties

Returns

Task<ulong>

Returns the ID of the created message.

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 Stream
filename string
text string
isTTS bool
embeds IEnumerable<Embed>
username string
avatarUrl string
options RequestOptions
isSpoiler bool
allowedMentions AllowedMentions
components MessageComponent
flags MessageFlags
threadId ulong?
threadName string
appliedTags ulong[]
poll PollProperties

Returns

Task<ulong>

Returns the ID of the created message.

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 string
text string
isTTS bool
embeds IEnumerable<Embed>
username string
avatarUrl string
options RequestOptions
isSpoiler bool
allowedMentions AllowedMentions
components MessageComponent
flags MessageFlags
threadId ulong?
threadName string
appliedTags ulong[]
poll PollProperties

Returns

Task<ulong>

Returns the ID of the created message.

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 string
isTTS bool
embeds IEnumerable<Embed>
username string
avatarUrl string
options RequestOptions
allowedMentions AllowedMentions
components MessageComponent
flags MessageFlags
threadId ulong?
threadName string
appliedTags ulong[]
poll PollProperties

Returns

Task<ulong>

Returns the ID of the created message.

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 string
isTTS bool
embeds IEnumerable<Embed>
username string
avatarUrl string
options RequestOptions
allowedMentions AllowedMentions
components MessageComponent
flags MessageFlags
threadId ulong?
threadName string
appliedTags ulong[]
poll PollProperties

Returns

Task<ulong>

Returns the ID of the created message.

Events

Log

public event Func<LogMessage, Task> Log

Event Type

Func<LogMessage, Task>