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.
- Variables:
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)
- async classmethod create(client, channel_id, name, avatar=<interactions.MISSING>)[source]#
Creates a webhook in a channel.
- Parameters:
- Returns:
The created webhook as object
- Return type:
- async classmethod get(client, webhook_id, webhook_token=<interactions.MISSING>)[source]#
Gets an existing webhook.
- async modify(name=<interactions.MISSING>, channel_id=<interactions.MISSING>, avatar=<interactions.MISSING>)[source]#
Modifies the current webhook.
- 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.
Important
The
components
argument requires an application-owned webhook.- Parameters:
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
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
- Returns:
The sent message, if present
- Return type:
Optional[Message]