Show / Hide Table of Contents

    Class DiscordWebhookClient

    Represents a webhook-only client. This client can be used to execute Discord webhooks.

    Inheritance
    Object
    DiscordWebhookClient
    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 = null, 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.

    Nullable<TimeSpan> timeout

    Timeout to use for HTTP requests. Set to InfiniteTimeSpan to disable timeouts.

    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.

    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
    String

    Logger

    Gets the logger for this client.

    Declaration
    public ILogger<DiscordWebhookClient> Logger { get; }
    Property Value
    Type Description
    ILogger<DiscordWebhookClient>

    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
    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 async Task<DiscordWebhook> AddWebhookAsync(ulong id, BaseDiscordClient client)
    Parameters
    Type Name Description
    UInt64 id

    ID of the webhook to register.

    BaseDiscordClient client

    Discord client to which the webhook will belong.

    Returns
    Type Description
    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 async Task<DiscordWebhook> AddWebhookAsync(ulong id, string token)
    Parameters
    Type Name Description
    UInt64 id

    The ID of the webhook to add.

    String token

    The token of the webhook to add.

    Returns
    Type Description
    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
    Task<DiscordWebhook>

    The registered webhook.

    BroadcastMessageAsync(DiscordWebhookBuilder)

    Broadcasts a message to all registered webhooks.

    Declaration
    public async Task<Dictionary<DiscordWebhook, DiscordMessage>> BroadcastMessageAsync(DiscordWebhookBuilder builder)
    Parameters
    Type Name Description
    DiscordWebhookBuilder builder

    Webhook builder filled with data to send.

    Returns
    Type Description
    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
    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
    UInt64 id

    ID of the webhook to unregister.

    Returns
    Type Description
    DiscordWebhook

    The unregistered webhook.

    Back to top © 2016-2022 DSharpPlus Contributors