Webhook Models#

New in version 4.3.0.

class interactions.api.models.webhook.Webhook(kwargs_dict=None, /, **other_kwargs)[source]#

A class object representing a Webhook.

  • id (Snowflake) – the id of the webhook

  • type (WebhookType) – the type of the webhook

  • guild_id (Snowflake) – the guild id this webhook is for, if any

  • channel_id (Snowflake) – the channel id this webhook is for, if any

  • user (User) – the user this webhook was created by (not returned when getting a webhook with its token)

  • name (str) – the default name of the webhook

  • avatar (str) – the default user avatar hash of the webhook

  • token (str) – the secure token of the webhook (returned for Incoming Webhooks)

  • application_id (Snowflake) – the bot/OAuth2 application that created this webhook

  • source_guild (Guild) – the guild of the channel that this webhook is following (returned for Channel Follower Webhooks)

  • source_channel (Channel) – the channel that this webhook is following (returned for Channel Follower Webhooks)

  • url (str) – the url used for executing the webhook (returned by the webhooks OAuth2 flow)

property created_at: datetime#

New in version 4.4.0.

Returns when the webhook was created.

async classmethod create(client, channel_id, name, avatar=<interactions.MISSING>)[source]#

Creates a webhook in a channel.

  • client (HTTPClient) – The HTTPClient of the bot, has to be set to bot._http.

  • channel_id (int) – The ID of the channel to create the webhook in.

  • name (str) – The name of the webhook.

  • avatar (Optional[Image]) – The avatar of the Webhook, if any.


The created webhook as object

Return type:


async classmethod get(client, webhook_id, webhook_token=<interactions.MISSING>)[source]#

Gets an existing webhook.

  • client (HTTPClient) – The HTTPClient of the bot, has to be set to bot._http.

  • webhook_id (int) – The ID of the webhook.

  • webhook_token (Optional[str]) – The token of the webhook, optional


The Webhook object

Return type:


async modify(name=<interactions.MISSING>, channel_id=<interactions.MISSING>, avatar=<interactions.MISSING>)[source]#

Modifies the current webhook.

  • name (Optional[str]) – The new name of the webhook

  • channel_id (int) – The channel id of the webhook. If not provided, the webhook token will be used for authentication

  • avatar (Optional[Image]) – The new avatar of the webhook


The modified webhook object

Return type:


async execute(content=<interactions.MISSING>, username=<interactions.MISSING>, avatar_url=<interactions.MISSING>, tts=<interactions.MISSING>, embeds=<interactions.MISSING>, allowed_mentions=<interactions.MISSING>, attachments=<interactions.MISSING>, components=<interactions.MISSING>, files=<interactions.MISSING>, thread_id=<interactions.MISSING>)[source]#

Executes the webhook. All parameters to this function are optional.


The components argument requires an application-owned webhook.

  • content (str) – the message contents (up to 2000 characters)

  • username (str) – override the default username of the webhook

  • avatar_url (str) – override the default avatar of the webhook

  • tts (bool) – true if this is a TTS message

  • attachments (Optional[List[Attachment]]) – The attachments to attach to the message. Needs to be uploaded to the CDN first

  • embeds (Union[Embed, List[Embed]]) – embedded rich content

  • allowed_mentions (Optional[Union[AllowedMentions, dict]]) – The allowed mentions for the message.

  • components (Union[ActionRow, Button, SelectMenu, List[ActionRow], List[Button], List[SelectMenu]]) – the components to include with the message

  • files (Union[File, List[File]]) – The files to attach to the message

  • thread_id (int) – Send a message to a specified thread within a webhook’s channel. The thread will automatically be unarchived


The sent message, if present

Return type:


async delete()[source]#

Deletes the webhook.

property avatar_url: str | None#

Returns the URL of the webhook’s avatar.


URL of the webhook’s avatar

Return type:


enum interactions.api.models.webhook.WebhookType(value)[source]#

An enumeration.

Member Type:


Valid values are as follows:

Incoming = <WebhookType.Incoming: 1>#
Channel_Follower = <WebhookType.Channel_Follower: 2>#
Application = <WebhookType.Application: 3>#