ClientCompoundWebhookEndpoints

Methods

__new__()

Compound components do not support instancing.

Sub-typing is supported, but the attributes are only proxied. Sub-types have no meaning by themselves.

Raises

RuntimeError

webhook_create(channel, name, ...)

Creates a webhook at the given channel.

This method is a coroutine.

ParameterTypeOptionalKeyword onlyDefaultDescription
channel

Channel, int

The channel of the created webhook.

name

str

The name of the new webhook. It's length can be in range [1:80].

avatar

None, bytes-like

None

The webhook's avatar. Can be 'jpg', 'png', 'webp', 'gif' image's raw data. However if set as 'gif', it will not have any animation.

Returns

webhook : Webhook

The created webhook.

Raises

TypeError

  • If channel was not given neither as Channel nor as int.
  • If avatar was not given neither as None, bytes-like.

ConnectionError

No internet connection.

DiscordException

If any exception was received from the Discord API.

AssertionError

  • If name was not given as str.
  • If name range is out of the expected range [1:80].
  • If avatar 's type is not any of the expected ones: 'jpg', 'png', 'webp', 'gif'.

webhook_delete(webhook)

Deletes the webhook.

This method is a coroutine.

ParameterTypeDescription
webhook

Webhook, int

The webhook to delete.

Raises

TypeError

If webhook was not given neither as Webhook, int.

ConnectionError

No internet connection.

DiscordException

If any exception was received from the Discord API.

See Also

.webhook_delete_token: Deleting webhook with Discord's webhook API.

webhook_delete_token(webhook, webhook)

Deletes the webhook through Discord's webhook API.

This method is a coroutine.

ParameterTypeDescription
webhook

Webhook, tuple(int, str)

The webhook to delete.

webhook

Webhook

The webhook to delete.

Raises

TypeError

If webhook was not given neither as Webhook neither as a tuple(int, str).

ConnectionError

No internet connection.

DiscordException

If any exception was received from the Discord API.

webhook_edit(webhook, ...)

Edits and updates the given webhook.

This method is a coroutine.

ParameterTypeOptionalKeyword onlyDescription
webhook

Webhook, int

The webhook to edit.

name

str

The webhook's new name. It's length can be in range [1:80].

avatar

None, bytes-like

The webhook's new avatar. Can be 'jpg', 'png', 'webp', 'gif' image's raw data. However if set as 'gif', it will not have any animation. If passed as None, will remove the webhook's current avatar.

channel

Channel, int

The webhook's channel.

Raises

TypeError

  • If webhook was not given neither as Webhook neither as int.
  • If avatar was not given neither as None nor as bytes-like.
  • If channel was not given neither as Channel neither as int.

ConnectionError

No internet connection.

DiscordException

If any exception was received from the Discord API.

AssertionError

  • If name was given but not as str.
  • If name 's length is out of range [1:80].
  • If avatar 's type is not any of the expected ones: 'jpg', 'png', 'webp', 'gif'.

See Also

.webhook_edit_token: Editing webhook with Discord's webhook API.

webhook_edit_token(webhook, ...)

Edits and updates the given webhook through Discord's webhook API.

This method is a coroutine.

ParameterTypeOptionalKeyword onlyDescription
webhook

Webhook, tuple(int, str)

The webhook to edit.

name

str

The webhook's new name. It's length can be between 1 and 80.

avatar

None, bytes-like

The webhook's new avatar. Can be 'jpg', 'png', 'webp', 'gif' image's raw data. However if set as 'gif', it will not have any animation. If passed as None, will remove the webhook's current avatar.

Returns

webhook : Webhook

The updated webhook.

Raises

TypeError

  • If webhook was not given neither as Webhook neither as a tuple(int, str).
  • If avatar was not given neither as None nor as bytes-like.

ConnectionError

No internet connection.

DiscordException

If any exception was received from the Discord API.

AssertionError

  • If name was given but not as str.
  • If name 's length is out of range [1:80].
  • If avatar 's type is not any of the expected ones: 'jpg', 'png', 'webp', 'gif'.

Notes

This endpoint cannot edit the webhook's channel, like .webhook_edit.

webhook_get(webhook)

Requests the webhook by it's id.

This method is a coroutine.

ParameterTypeDescription
webhook

Webhook, int

The webhook to update or the webhook's id to get.

Returns

webhook : Webhook

Raises

TypeError

If webhook was not given neither as Webhook neither as int.

ConnectionError

No internet connection.

DiscordException

If any exception was received from the Discord API.

Notes

If the webhook already loaded and if it's guild's webhooks are up to date, no request is done.

See Also

.webhook_get_token: Getting webhook with Discord's webhook API.

webhook_get_all_channel(channel)

Requests all the webhooks of the channel.

This method is a coroutine.

ParameterTypeDescription
channel

Channel, int

The channel, what's webhooks will be requested.

Returns

webhooks : list of Webhook objects

Raises

TypeError

If channel was not given neither as Channel, neither as int.

ConnectionError

No internet connection.

DiscordException

If any exception was received from the Discord API.

You may expect the following exceptions:

Error codeInternal nameReason
10003unknown_channelThe channel not exists.
50013missing_permissionsYou need manage_webhooks permission. (Or the client has no access to the channel.)
60003mfa_requiredYou need to have multi-factor authorization to do this operation (guild setting dependent). For bot accounts it means their owner needs mfa.

Discord drops Forbidden (403), code = 50013: Missing Permissions instead of Forbidden (403), code = 50001: Missing Access.

AssertionError

If channel was given as a channel's identifier but it detectably not refers to a Channel.

Notes

No request is done, if the passed channel is partial, or if the channel's guild's webhooks are up to date.

webhook_get_all_guild(guild)

Requests the webhooks of the given guild.

This method is a coroutine.

ParameterTypeDescription
guild

Guild, int

The guild, what's webhooks will be requested.

Returns

webhooks : list of Webhook objects

Raises

TypeError

If guild was not given neither as Guild nor as int.

ConnectionError

No internet connection.

DiscordException

If any exception was received from the Discord API.

Notes

No request is done, if the guild's webhooks are up to date.

webhook_get_own_channel(channel)

Requests the webhooks of the given channel and returns the first owned one.

ParameterTypeDescription
channel

Channel, int

The channel, what's webhooks will be requested.

Returns

webhooks : list of Webhook objects

webhook_get_token(webhook)

Requests the webhook through Discord's webhook API. The client do not needs to be in the guild of the webhook.

This method is a coroutine.

ParameterTypeDescription
webhook

Webhook, tuple(int, str)

The webhook to update or the webhook's id and token.

Returns

webhook : Webhook

Raises

TypeError

If webhook was not given neither as Webhook neither as a tuple(int, str).

ConnectionError

No internet connection.

DiscordException

If any exception was received from the Discord API.

Notes

If the webhook already loaded and if it's guild's webhooks are up to date, no request is done.

webhook_message_create(webhook, ...)

Sends a message with the given webhook. If there is nothing to send, or if wait was not passed as True returns None.

This method is a coroutine.

ParameterTypeOptionalKeyword onlyDefaultDescription
webhook

Webhook, tuple(int, str)

The webhook through what will the message be sent.

*positional_parameters

Positional parameters

Additional parameters to create the message with.

thread

None, Channel, int

None

The thread of the webhook's channel where the message should be sent.

wait

None, bool

None

Whether we should wait for the message to send and receive it's data as well.

**keyword_parameters

Keyword parameters

Additional parameters to create the message with.

allowed_mentions

None, AllowedMentionProxy, str, UserBase, Role, list of (str, UserBase, Role)

Which user or role can the message ping (or everyone). Check parse_allowed_mentions for details.

applied_tag_ids

None, (list | tuple)<int | ForumTag>, int, ForumTag

The tags' identifier which have been applied to the thread. Applicable for threads of a forum-like channels.

applied_tags

None, (list | tuple)<int | ForumTag>, int, ForumTag

Alternative for applied_tag_ids.

attachments

None, object

Attachments to send.

avatar_url

None, str

None

The message's author's avatar's url. Defaults to the webhook's avatar' url by Discord.

components

None, Component, (tuple | list)<Component, (tuple | list)<Component>>

Components attached to the message.

content

None, str

The message's content if given.

embed

None, Embed

Alternative for embeds.

embeds

None, list<Embed>

The new embedded content of the message.

file

None, object

Alternative for attachments.

files

None, object

Alternative for attachments.

flags

int, MessageFlag

The message's flags.

name

None, str

None

The message's author's new name. Default to the webhook's name by Discord.

silent

bool

False

Whether the message should be delivered silently.

suppress_embeds

bool

False

Whether the message's embeds should be suppressed initially.

thread_name

None, str

The thread's name to create. Applicable only in forum-like channels.

tts

bool

False

Whether the message is text-to-speech.

Returns

message : Message, None

Returns None if there is nothing to send or if wait was given as False(so by default).

Raises

TypeError

  • If a parameter's type is incorrect.

ConnectionError

No internet connection.

DiscordException

If any exception was received from the Discord API.

See Also

webhook_message_delete(webhook, message)

Deletes the message sent by the webhook.

This method is a coroutine.

ParameterTypeDescription
webhook

Webhook, tuple(int, str)

The webhook who created the message.

message

Message, int

The webhook's message to delete.

Raises

TypeError

  • If message was not given neither as Message, int.
  • If webhook was not given neither as Webhook neither as a tuple(int, str).

ConnectionError

No internet connection.

DiscordException

If any exception was received from the Discord API.

AssertionError

If message was detectably not sent by the webhook.

See Also

webhook_message_edit(webhook, message, ...)

Edits the message sent by the given webhook. The message's author must be the webhook itself.

ParameterTypeOptionalKeyword onlyDescription
webhook

Webhook, tuple(int, str)

The webhook who created the message.

message

Message, int

The webhook's message to edit.

*positional_parameters

Positional parameters

Additional parameters to edit the message with.

**keyword_parameters

Keyword parameters

Additional parameters to edit the message with.

allowed_mentions

None, AllowedMentionProxy, str, UserBase, Role, list of (str, UserBase, Role)

Which user or role can the message ping (or everyone). Check parse_allowed_mentions for details.

attachments

None, object

Attachments to send.

components

None, Component, (tuple | list)<Component, (tuple | list)<Component>>

Components attached to the message.

Pass it as None remove the actual ones.

content

None, str

The new content of the message.

embed

None, Embed

Alternative for embeds.

embeds

None, list<Embed>

The new embedded content of the message.

By passing it as None, you can remove the old.

file

None, object

Alternative for attachments.

files

None, object

Alternative for attachments.

flags

int, MessageFlag

The message's new flags.

suppress_embeds

bool

Whether the message's embeds should be suppressed or unsuppressed.

Raises

TypeError

  • If a parameter's type is incorrect.

ConnectionError

No internet connection.

DiscordException

If any exception was received from the Discord API.

Notes

Embed messages ignore suppression with their endpoint, not like .message_edit endpoint.

Editing the message with empty string is broken.

See Also

webhook_message_get(webhook, message_id)

Gets a previously sent message with the webhook.

This method is a coroutine.

ParameterTypeDescription
webhook

Webhook, tuple(int, str)

The webhook who created the message.

message_id

int

The webhook's message's identifier to get.

Returns

message : Message

Raises

TypeError

  • If webhook was not given neither as Webhook neither as a tuple(int, str).
  • If message_id was not given as int.

ConnectionError

No internet connection.

DiscordException

If any exception was received from the Discord API.

See Also