Webhooks¶
WebhookType¶
Webhook¶
- asyncdelete
- asyncdelete_message
- asyncedit
- asyncedit_message
- asyncexecute
- asyncfetch_message
- asyncrespond_to_autocomplete
- asyncrespond_with_message
- asyncrespond_with_modal
- asyncsend_followup_message
- class acord.Webhook(*, conn: Any = None, id: acord.models.Snowflake, type: acord.webhooks.types.WebhookType, guild_id: acord.models.Snowflake = None, channel_id: acord.models.Snowflake = None, user: acord.models.user.User = None, name: str = None, avatar: pydantic.networks.AnyHttpUrl = None, token: str = None, application_id: acord.models.Snowflake = None, url: str = None)[source]¶
Representation of a discord webhook
This class can simply be used for sending simple messages, and editing and deleting them. Only IF you stick to the default session.
If you pass your client through the args, or overwrite
Webhook.connwithClient.http. Your able to properly interact with the generated message object.Note
When dealing with interactions, it is recommended to use the webhook class, instead of
Interaction- async delete(*, reason: Optional[str] = None, with_token: bool = True, auth: Optional[str] = None) None[source]¶
This function is a coroutine.
Deletes webhook
- async delete_message(message_id: acord.models.Snowflake, *, thread_id: Optional[acord.models.Snowflake] = None, reason: Optional[str] = None, use_application_id: bool = False) None[source]¶
This function is a coroutine.
Deletes a message sent by webhook
- async edit(*, reason: Optional[str] = None, with_token: bool = True, auth: Optional[str] = None, **kwds) acord.webhooks.webhook.Webhook[source]¶
This function is a coroutine.
Edits webhook.
- Parameters
name (
str) – New name of webhook, still cannot be calledclydeavatar (
File) – New avatar for webhookchannel_id (
Snowflake) – New channel to move webhook toreason (
str) – reason for editing webhookwith_token (
bool) – Whether to modify with token or not, defaults toTrueauth (
str) – If not with_token, auth is your BOT TOKEN, which will be used to make request
- async edit_message(message_id: acord.models.Snowflake, *, thread_id: Optional[acord.models.Snowflake] = None, use_application_id: bool = False, **kwds) acord.models.message.WebhookMessage[source]¶
This function is a coroutine.
Edits a previously sent message from this webhook
Note
This function accepts all parameters from
Message.edit, as a well a few extras which are documented below.- Parameters
message_id (
Snowflake) – ID of message to editthread_id (
Snowflake) – ID of thread message was sent inuse_application_id (
bool) – Whether to use the application ID instead of the Webhook ID
- async execute(*, wait: bool = False, thread_id: Optional[acord.models.Snowflake] = None, **kwds) Optional[acord.models.message.WebhookMessage][source]¶
This function is a coroutine.
Executes a webhook.
Note
This function accepts all parameters from
TextChannel.send, as a well a few extras which are documented below.
- async fetch_message(message_id: acord.models.Snowflake, *, thread_id: Optional[acord.models.Snowflake] = None, use_application_id: bool = False) acord.models.message.WebhookMessage[source]¶
This function is a coroutine.
Fetches a message sent by the webhook
- Parameters
message_id (
Snowflake) – ID of message to fetchthread_id (
Snowflake) – ID of thread message is inuse_application_id (
bool) – Whether to use the application id instead of the webhook id when fetching message
- async respond_to_autocomplete(choices: List[acord.ext.application_commands.option.AutoCompleteChoice]) None[source]¶
This function is a coroutine.
Responds to an interaction with a list of choices
- Parameters
choices (List[
AutoCompleteChoice]) – List of choices to return the user, can be a list of dicts with the mapping name: value
- async respond_with_message(**kwds) None[source]¶
This function is a coroutine.
Responds to an interaction using a regular message
Danger
This method should only be if
Webhook.typeis3. As it will fail for any other type of webhook.Note
All parameters from
TextChannel.send()are valid, additional parameters documented below- Parameters
flags (
IMessageFlags) – Flags for messageack (
bool) – Whether to ack the response, giving the client15mins to edit to this response.
- async respond_with_modal(modal: acord.bases.components.Modal) None[source]¶
This function is a coroutine.
Responds to an interaction using a modal.
- Parameters
modal (
Modal) – Modal to respond with
- async send_followup_message(**kwds) None[source]¶
This function is a coroutine.
Sends a followup message to an interaction
Note
All parameters from
TextChannel.send()are valid, any additional parameters documented below- Parameters
flags (
IMessageFlags) – Flags for message
- application_id: Optional[acord.models.Snowflake]¶
the bot/OAuth2 application that created this webhook
- avatar: Optional[pydantic.networks.AnyHttpUrl]¶
the default user avatar hash of the webhook
- channel_id: Optional[acord.models.Snowflake]¶
the channel id this webhook is for, if any
- guild_id: Optional[acord.models.Snowflake]¶
the guild id this webhook is for, if any
- id: acord.models.Snowflake¶
the id of the webhook
- type: acord.webhooks.types.WebhookType¶
the type of the webhook
- user: Optional[acord.models.user.User]¶
the user this webhook was created by (not returned when getting a webhook with its token)
WebhookConnection¶
- asyncrequest
- class acord.webhooks.connection.WebhookConnection(*, loop: asyncio.events.AbstractEventLoop = <_UnixSelectorEventLoop running=False closed=False debug=False>, session: typing.Optional[aiohttp.client.ClientSession] = None, client: typing.Optional[typing.Any] = None, **kwds)[source]¶
Base webhook connection, wraps the session to be compatible with other ACord objects.
- Parameters
loop (
asyncio.AbstractEventLoop) – Loop to create connection off ofsession (
ClientSession) – A pre-existing session to useclient (
Client) –Client to attach webhook to.
Danger
If this param is provided, :param:`WebhookConnection.session` is ignored.
We will instead use the session generated by the client
**kwds –
Additional kwargs to pass through session, if it has not been provided.
Note
You may not provide the loop param through kwds, use :param:`WebhookConnection.loop`.