Class DiscordWebhookClient
Represents a webhook-only client. This client can be used to execute Discord webhooks.
Inheritance
Namespace: DSharpPlus
Assembly: cs.temp.dll.dll
Syntax
public class DiscordWebhookClient
Constructors
DiscordWebhookClient()
Creates a new webhook client.
Declaration
public DiscordWebhookClient()
DiscordWebhookClient(IWebProxy, Nullable<TimeSpan>, Boolean, ILoggerFactory, LogLevel, String)
Creates a new webhook client, with specified HTTP proxy, timeout, and logging settings.
Declaration
public DiscordWebhookClient(IWebProxy proxy = null, TimeSpan? timeout = default(TimeSpan? ), bool useRelativeRateLimit = true, ILoggerFactory loggerFactory = null, LogLevel minimumLogLevel = null, string logTimestampFormat = "yyyy-MM-dd HH:mm:ss zzz")
Parameters
Type | Name | Description |
---|---|---|
IWebProxy | proxy | Proxy to use for HTTP connections. |
System.Nullable<TimeSpan> | timeout | Timeout to use for HTTP requests. Set to System.Threading.Timeout.InfiniteTimeSpan to disable timeouts. |
System.Boolean | useRelativeRateLimit | Whether to use the system clock for computing rate limit resets. See UseRelativeRatelimit for more details. |
ILoggerFactory | loggerFactory | The optional logging factory to use for this client. |
LogLevel | minimumLogLevel | The minimum logging level for messages. |
System.String | logTimestampFormat | The timestamp format to use for the logger. |
Properties
AvatarUrl
Gets or set the avatar override for registered webhooks. Note that this only takes effect when broadcasting.
Declaration
public string AvatarUrl { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Username
Gets or sets the username override for registered webhooks. Note that this only takes effect when broadcasting.
Declaration
public string Username { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Webhooks
Gets the collection of registered webhooks.
Declaration
public IReadOnlyList<DiscordWebhook> Webhooks { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<DiscordWebhook> |
Methods
AddWebhook(DiscordWebhook)
Registers a webhook with this client. This reuses the supplied webhook object.
Declaration
public DiscordWebhook AddWebhook(DiscordWebhook webhook)
Parameters
Type | Name | Description |
---|---|---|
DiscordWebhook | webhook | Webhook to register. |
Returns
Type | Description |
---|---|
DiscordWebhook | The registered webhook. |
AddWebhookAsync(UInt64, BaseDiscordClient)
Registers a webhook with this client. This retrieves a webhook using the supplied full discord client.
Declaration
public Task<DiscordWebhook> AddWebhookAsync(ulong id, BaseDiscordClient client)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | id | ID of the webhook to register. |
BaseDiscordClient | client | Discord client to which the webhook will belong. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DiscordWebhook> | The registered webhook. |
AddWebhookAsync(UInt64, String)
Registers a webhook with this client. This retrieves a webhook based on the ID and token supplied.
Declaration
public Task<DiscordWebhook> AddWebhookAsync(ulong id, string token)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | id | The ID of the webhook to add. |
System.String | token | The token of the webhook to add. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DiscordWebhook> | The registered webhook. |
AddWebhookAsync(Uri)
Registers a webhook with this client. This retrieves a webhook from webhook URL.
Declaration
public Task<DiscordWebhook> AddWebhookAsync(Uri url)
Parameters
Type | Name | Description |
---|---|---|
Uri | url | URL of the webhook to retrieve. This URL must contain both ID and token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DiscordWebhook> | The registered webhook. |
BroadcastMessageAsync(DiscordWebhookBuilder)
Broadcasts a message to all registered webhooks.
Declaration
public Task<Dictionary<DiscordWebhook, DiscordMessage>> BroadcastMessageAsync(DiscordWebhookBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
DiscordWebhookBuilder | builder | Webhook builder filled with data to send. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Dictionary<DiscordWebhook, DiscordMessage>> |
Finalize()
Declaration
protected void Finalize()
GetRegisteredWebhook(UInt64)
Gets a registered webhook with specified ID.
Declaration
public DiscordWebhook GetRegisteredWebhook(ulong id)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | id | ID of the registered webhook to retrieve. |
Returns
Type | Description |
---|---|
DiscordWebhook | The requested webhook. |
RemoveWebhook(UInt64)
Unregisters a webhook with this client.
Declaration
public DiscordWebhook RemoveWebhook(ulong id)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | id | ID of the webhook to unregister. |
Returns
Type | Description |
---|---|
DiscordWebhook | The unregistered webhook. |