Skip to content

Webhook

Represents a Discord webhook.


Types



RatelimitInformation

Key Type Description
Limit number The maximum amount of requests you can make.
Remaining number The remaining amount of requests you can make.
Reset Datetime Represents the timestamp of when the ratelimit bucket resets.
ResetAfter number The exact time in seconds to wait until the ratelimit bucket resets.
ResetAfterSafe number Same as ResetAfter but with 0.5 seconds of delay added.
Bucket string The current ratelimit bucket id.
RatelimitInformation Vs RatelimitedInformation

RatelimitInformation is used to prevent getting ratelimited from the proxy, while RatelimitedInformation is used to handle a ratelimit response.




RatelimitedInformation

Key Type Description
Scope string The scope you are ratelimited from.
RetryAfter number The exact time in milliseconds until you are able to send messages again.
RetryAfterSafe number Same as RetryAfter but with 0.5 seconds of delay added.
RatelimitInformation Vs RatelimitedInformation

RatelimitInformation is used to prevent getting ratelimited from the proxy, while RatelimitedInformation is used to handle a ratelimit response.




ProxyInformation

Key Type Description
Proxy true? If proxy is true, the proxy isn't responsible for 4xx HTTP errors.
Message string? A message from the proxy.
Reason string? A reason for your ban.
Error string? An error message.




RequestStatus

Key Type Description
Success boolean Indicates if the request succeeded.
StatusCode number Contains the request's status code.
StatusMessage string Contains the request's status message.
ProxyInformation ProxyInformation? Contains information sent by the proxy.
RatelimitInformation (RatelimitInformation | RatelimitedInformation)? Contains information on ratelimiting.
Note

RatelimitInformation will contain a table of type RatelimitedInformation if the StatusCode returned is 429. Otherwise it will be a table of type RatelimitInformation.




Properties



Id

A string containing the webhook's id.




Token

A string containing the webhook's token.

Danger

Never share this with anyone! If this string is made public it gives everyone full access to your webhook. If you think someone has your webhook's token the best course of action to take is to delete the webhook and create a new one.




BaseUrl

A string containing the webhook's base url.

Danger

Never share this with anyone! If this string is made public it gives everyone full access to your webhook. If you think someone has your webhook's token the best course of action to take is to delete the webhook and create a new one.




Constructors



new(id, token, customProxyUrl)

Constructs a new Webhook instance from an id, token and an optional custom proxy url. Returns a new Webhook instance.

Custom proxy url example

"https://webhook.lewisakura.moe"

Parameters




fromUrl(webhookUrl, customProxyUrl)

Constructs a new Webhook instance from a webhook url and an optional custom proxy url. Returns a new Webhook instance.

Custom proxy url example

"https://webhook.lewisakura.moe"

Parameters




Methods



SendMessage(content, embeds, queue, waitForMessage, optionalSendMessageInfo)

Sends a message to the webhook's channel. Returns a tuple containing 2 items, an optional Message instance and a table of type RequestStatus.

Default Parameter Values

queue: true

waitForMessage: false

Info

If both queue and waitForMessage are true, a message object will NOT be returned.

If queue is true, RequestStatus.RatelimitInformation will be nil.

Tip

If you dont feel like making your own ratelimit handler set queue to true. This will ensure the message is sent to Discord. The only down side is it may take a few more seconds to be sent depending on how busy the proxy's queue is.

Parameters

  • content : string? - The message's content.
  • embeds : { Embed }? - Embeds that'll be attached to the message.
  • queue : boolean? - Whether to queue the request.
  • waitForMessage : boolean? - Whether to wait for a Message instance to be returned.
  • optionalSendMessageInfo : OptionalSendMessageInfo? - Contains extra information for the request.




SendMessageInThread(threadId, content, embeds, queue, waitForMessage, optionalSendMessageInfo)

Sends a message to a thread in the webhook's channel. Returns a tuple containing 2 items, an optional Message instance and a table of type RequestStatus.

Default Parameter Values

queue: true

waitForMessage: false

Info

If both queue and waitForMessage are true, a message object will NOT be returned.

If queue is true, RequestStatus.RatelimitInformation WILL be null.

Tip

If you dont feel like making your own ratelimit handler set queue to true. This will ensure the message is sent to Discord. The only down side is it may take a few more seconds to be sent depending on how busy the proxy's queue is.

Parameters

  • threadId : string? - The id of the thread the message will be sent to.
  • content : string? - The message's content.
  • embeds : { Embed }? - Embeds that'll be attached to the message.
  • queue : boolean? - Whether to queue the request.
  • waitForMessage : boolean? - Whether to wait for a Message instance to be returned.
  • optionalSendMessageInfo : OptionalSendMessageInfo? - Contains extra information for the request.




EditMessage(messageId, content, embeds)

Edits a message sent by the webhook. Returns a tuple containing 2 items, a Message instance and a table of type RequestStatus.

Parameters

  • messageId : string - The id of the message.
  • content : string? - The new content.
  • embeds : { Embed }? - The new embeds.




EditMessageInThread(threadId, messageId, content, embeds)

Edits a message in a thread sent by the webhook. Returns a tuple containing 2 items, a Message instance and a table of type RequestStatus.

Parameters

  • threadId : string - The id of the thread the message is in.
  • messageId : string - The id of the message.
  • content : string? - The new content.
  • embeds : { Embed }? - The new embeds.




DeleteMessage(messageId)

Deletes a message sent by the webhook. Returns a table of type RequestStatus.

Parameters

  • messageId : string - The id of the message.




DeleteMessageInThread(threadId, messageId)

Deletes a message in a thread sent by the webhook. Returns a table of type RequestStatus.

Parameters

  • threadId : string - The id of the thread the message is in.
  • messageId : string - The id of the message.




_ValidateSendMessageRequest(content, embeds, optionalExecuteInfo)

Validates the request to avoid making a bad request to Discord. Returns a tuple with 2 items a boolean and an optional string.

Internal Code warning

This method is not meant to be used outside of Voyager's internal code.

Info

The boolean value indicates whether the validation was successful, and the optional string contains the error message if validation failed.

Parameters

  • content : string? - The content of the message.
  • embeds : { Embed }? - Embeds that'll be attached to the message.
  • optionalExecuteInfo : OptionalSendMessageInfo? - Any extra info for the request.




_ValidateEditMessageRequest(content, embeds)

Validates the request to avoid making a bad request to Discord. Returns a tuple with 2 items a boolean and an optional string.

Internal Code warning

This method is not meant to be used outside of Voyager's internal code.

Info

The boolean value indicates whether the validation was successful, and the optional string contains the error message if validation failed.

Parameters

  • content : string? - The new content of the message.
  • embeds : { Embed }? - The new embeds that'll be attached to the message.




_Request(url, method, body, contentType)

This method is used to make HTTP requests to the proxy. Returns a tuple containing 2 items, a table containing the response body and a table of type RequestStatus.

Internal Code warning

This method is not meant to be used outside of Voyager's internal code.

Parameters

  • url : string - The url the request will be sent to.
  • method : string - The HTTP method.
  • body : {}? - The body of the request.
  • contentType : string - The content type of the request.