Webhook

discord_http.webhook module

class discord_http.webhook.PartialWebhook(*, state: DiscordAPI, id: int, token: str | None = None)[source]

Bases: PartialBase

async delete(*, reason: str | None = None) None[source]

Delete the webhook

Parameters:

reason (Optional[str]) – The reason for deleting the webhook

async edit(*, name: str | None = <MISSING>, avatar: ~discord_http.file.File | bytes | None = <MISSING>, channel_id: int | None = <MISSING>, reason: str | None = None) Webhook[source]

Edit the webhook

Parameters:
  • name (Optional[str]) – Name of the webhook

  • avatar (Optional[File]) – Avatar of the webhook

  • channel_id (Optional[int]) – Channel ID to move the webhook to

  • reason (Optional[str]) – Reason for the audit log

Returns:

The webhook that was edited

Return type:

Webhook

async fetch() Webhook[source]

Webhook: Fetch the webhook

async send(content: str | None = MISSING, *, username: str | None = MISSING, avatar_url: str | None = MISSING, embed: Embed | None = MISSING, embeds: list[Embed] | None = MISSING, file: File | None = MISSING, files: list[File] | None = MISSING, ephemeral: bool | None = False, view: View | None = MISSING, type: ResponseType | int = 4, allowed_mentions: AllowedMentions | None = MISSING, wait: Literal[False], thread_id: int | None = MISSING, poll: 'Poll' | None = MISSING) None[source]
async send(content: str | None = MISSING, *, username: str | None = MISSING, avatar_url: str | None = MISSING, embed: Embed | None = MISSING, embeds: list[Embed] | None = MISSING, file: File | None = MISSING, files: list[File] | None = MISSING, ephemeral: bool | None = False, view: View | None = MISSING, type: ResponseType | int = 4, allowed_mentions: AllowedMentions | None = MISSING, wait: bool = True, thread_id: int | None = MISSING, poll: 'Poll' | None = MISSING) WebhookMessage

Send a message with the webhook

Parameters:
  • content (Optional[str]) – Content of the message

  • username (Optional[str]) – Username of the webhook

  • avatar_url (Optional[str]) – Avatar URL of the webhook

  • embed (Optional[Embed]) – Embed of the message

  • embeds (Optional[list[Embed]]) – Embeds of the message

  • file (Optional[File]) – File of the message

  • files (Optional[Union[list[File], File]]) – Files of the message

  • ephemeral (bool) – Whether the message should be sent as ephemeral

  • view (Optional[View]) – Components of the message

  • type (Optional[ResponseType]) – Which type of response should be sent

  • allowed_mentions (Optional[AllowedMentions]) – Allowed mentions of the message

  • wait (bool) – Whether to wait for the message to be sent

  • thread_id (Optional[int]) – Thread ID to send the message to

  • poll (Optional[Poll]) – Poll to send with the message

Returns:

The message that was sent, if wait is True.

Return type:

Optional[WebhookMessage]

Raises:

ValueError

  • If the webhook has no token - If avatar_url does not start with https://

class discord_http.webhook.Webhook(*, state: DiscordAPI, data: dict)[source]

Bases: PartialWebhook

property channel: PartialChannel | None

Returns the channel the webhook is in

Type:

Optional[PartialChannel]

classmethod from_state(*, state: DiscordAPI, data: dict) Webhook[source]

Creates a webhook from data, usually used for followup responses

Parameters:
  • state (DiscordAPI) – The state to use for the webhook

  • data (dict) – The data to use for the webhook

Returns:

The webhook that was created

Return type:

Webhook

property guild: PartialGuild | None

Returns the guild the webhook is in

Type:

Optional[PartialGuild]