curious.dataclasses.webhook

Wrappers for Webhook objects.

Classes

Webhook(client, **kwargs) Represents a webhook on the guild.
class curious.dataclasses.webhook.Webhook(client, **kwargs) → None[source]

Bases: curious.dataclasses.bases.Dataclass

Represents a webhook on the guild. Messages in a guild can be sent by either a Member or a Webhook object - curious makes a key distinction between them. These classes are mostly compatible and don’t require much effort to use them generically.

@event("message_create")
async def handle_messages(ctx, message: Message):
    author = message.author  # can be Webhook or Member

Inspects the stack to ensure we’re being called correctly.

user

The user object associated with this webhook.

guild_id

The ID of the Guild associated with this object.

channel_id

The ID of the Channel associated with this object.

token

The token associated with this webhook. This is None if the webhook was received from a Message object.

owner

The owner of this webhook.

default_name

The default name of this webhook.

_default_avatar

The default avatar of this webhook.

default_avatar_url
Return type:str
Returns:The default avatar URL for this webhook.
avatar_url
Return type:str
Returns:The computed avatar URL for this webhook.
name
Return type:str
Returns:The computed name for this webhook.
guild
Return type:Guild
Returns:The Guild this webhook is in.
channel
Return type:Channel
Returns:The Channel this webhook is in.
classmethod await create(*, name, avatar)[source]

Creates a new webhook.

Parameters:
  • channel (Channel) – The Channel to create the webhook in.
  • name (str) – The name of the webhook to create.
  • avatar (bytes) – The bytes data for the webhook’s default avatar.
Return type:

Webhook

Returns:

A new Webhook.

await get_token()[source]

Gets the token for this webhook, if no token was set earlier.

Return type:str
Returns:The token for the webhook.
await delete()[source]

Deletes the webhook.

You must either be the owner of this webhook, or the webhook must have a token associated to delete it.

Return type:None
await edit(*, name=None, avatar=None)[source]

Edits this webhook.

Parameters:
  • name (Optional[str]) – The new name for this webhook.
  • avatar (Optional[bytes]) – The bytes-encoded content of the new avatar.
Return type:

Webhook

Returns:

The webhook object.

await execute(*, content=None, username=None, avatar_url=None, embeds=None, wait=False)[source]

Executes the webhook.

Parameters:
  • content (Optional[str]) – Any raw content to send.
  • username (Optional[str]) – A username to override the default username of the webhook with.
  • avatar_url (Optional[str]) – The URL for the avatar to override the default avatar with.
  • embeds (Optional[List[Embed]]) – A list of embeds to add to the message.
  • wait (bool) – Should we wait for the message to arrive before returning?
Return type:

Union[None, str]

snowflake_timestamp
Return type:datetime
Returns:The timestamp of the snowflake.