Webhook

discord_http.webhook module

class discord_http.webhook.PartialWebhook(*, state, id, token=None)

Bases: PartialBase

Parameters:
async delete(*, reason=None) None

Delete the webhook.

Parameters:

reason (str | None) – The reason for deleting the webhook

Return type:

None

async edit(*, name=<MISSING>, avatar=<MISSING>, channel_id=<MISSING>, reason=None) Webhook

Edit the webhook.

Parameters:
  • name (str | None) – Name of the webhook

  • avatar (File | bytes | None) – Avatar of the webhook

  • channel_id (int | None) – Channel ID to move the webhook to

  • reason (str | None) – Reason for the audit log

Return type:

Webhook

Returns:

The webhook that was edited

async fetch() Webhook

Fetch the webhook.

Return type:

Webhook

async send(content=<MISSING>, *, username=<MISSING>, avatar_url=<MISSING>, embed=<MISSING>, embeds=<MISSING>, file=<MISSING>, files=<MISSING>, ephemeral=False, view=<MISSING>, type=4, allowed_mentions=<MISSING>, wait=True, flags=<MISSING>, thread_id=<MISSING>, poll=<MISSING>) WebhookMessage | None

Send a message with the webhook.

Parameters:
  • content (str | None) – Content of the message

  • username (str | None) – Username of the webhook

  • avatar_url (str | None) – Avatar URL of the webhook

  • embed (Embed | None) – Embed of the message

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

  • file (File | None) – File of the message

  • files (list[File] | None) – Files of the message

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

  • view (View | None) – Components of the message

  • type (ResponseType | int) – Which type of response should be sent

  • allowed_mentions (AllowedMentions | None) – Allowed mentions of the message

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

  • flags (MessageFlags | None) – Flags of the message

  • thread_id (int | None) – Thread ID to send the message to

  • poll (Poll | None) – Poll to send with the message

Return type:

WebhookMessage | None

Returns:

The message that was sent, if wait is True.

Raises:

ValueError

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

class discord_http.webhook.Webhook(*, state, data)

Bases: PartialWebhook

Parameters:
property channel: PartialChannel | None

Returns the channel the webhook is in.

classmethod from_state(*, state, data) Webhook

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

Return type:

Webhook

Returns:

The webhook that was created

property guild: Guild | PartialGuild | None

Returns the guild the webhook is in.