Webhook

class discord_limits.paths.WebhookPaths(client)
Parameters:

client (discord_limits.DiscordClient) – The DiscordClient instance to use.

async create_webhook(channel_id, name, reason=None)

Create a webhook.

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

  • name (str) – Name of the webhook (1-80 characters).

  • reason (str, optional) – A reason for this action that will be displayed in the audit log, by default None

Returns:

A webhook object.

Return type:

ClientResponse

async get_channel_webhooks(channel_id)

Get a list of webhooks for a channel.

Parameters:

channel_id (int) – The ID of the channel to get the webhooks for.

Returns:

A list of webhook objects.

Return type:

ClientResponse

async get_guild_webhooks(guild_id)

Get a list of webhooks for a guild.

Parameters:

guild_id (int) – The ID of the guild to get the webhooks for.

Returns:

A list of webhook objects.

Return type:

ClientResponse

async get_webhook(webhook_id)

Get a webhook.

Parameters:

webhook_id (int) – The ID of the webhook to get.

Returns:

A webhook object.

Return type:

ClientResponse

async get_webhook_with_token(webhook_id, webhook_token)

Get a webhook with a token.

Parameters:
  • webhook_id (int) – The ID of the webhook to get.

  • webhook_token (str) – The token of the webhook to get.

Returns:

A webhook object.

Return type:

ClientResponse

async edit_webhook(webhook_id, name=None, channel_id=None, reason=None)

Edit a webhook.

Parameters:
  • webhook_id (int) – The ID of the webhook to edit.

  • name (str, optional) – The default name of the webhook, by default None

  • channel_id (int, optional) – The new channel id this webhook should be moved to, by default None

  • reason (str, optional) – A reason for this action that will be displayed in the audit log, by default None

Returns:

A webhook object.

Return type:

ClientResponse

async edit_webhook_with_token(webhook_id, webhook_token, name=None, reason=None)

Edit a webhook with a token.

Parameters:
  • webhook_id (int) – The ID of the webhook to edit.

  • webhook_token (str) – The token of the webhook to edit.

  • name (str, optional) – The default name of the webhook, by default None

  • reason (str, optional) – A reason for this action that will be displayed in the audit log, by default None

Returns:

A webhook object.

Return type:

ClientResponse

async delete_webhook(webhook_id, reason=None)

Delete a webhook.

Parameters:
  • webhook_id (int) – The ID of the webhook to delete.

  • reason (str, optional) – A reason for this action that will be displayed in the audit log, by default None

Returns:

The response from Discord.

Return type:

ClientResponse

async delete_webhook_with_token(webhook_id, webhook_token, reason=None)

Delete a webhook with a token.

Parameters:
  • webhook_id (int) – The ID of the webhook to delete.

  • webhook_token (str) – The token of the webhook to delete.

  • reason (str, optional) – A reason for this action that will be displayed in the audit log, by default None

Returns:

The response from Discord.

Return type:

ClientResponse

async execute_webhook(webhook_id, webhook_token, wait=False, thread_id=None, content=None, username=None, avatar_url=None, tts=False, embeds=None, allowed_mentions=None, components=None)

Execute a webhook.

Parameters:
  • webhook_id (int) – The ID of the webhook to execute.

  • webhook_token (str) – The token of the webhook to execute.

  • wait (bool, optional) – Waits for server confirmation of message send before response, and returns the created message body, by default False

  • thread_id (int, optional) – Send a message to the specified thread within a webhook’s channel, by default None

  • content (str, optional) – The message contents (up to 2000 characters), by default None

  • username (str, optional) – Override the default username of the webhook, by default None

  • avatar_url (str, optional) – Override the default avatar of the webhook, by default None

  • tts (bool, optional) – True if this is a TTS message, by default False

  • embeds (List[dict], optional) – Embedded rich content, by default None

  • allowed_mentions (Any, optional) – Allowed mentions for the message, by default None

  • components (List[Any], optional) – The components to include with the message, by default None

Returns:

The response from Discord.

Return type:

ClientResponse

Raises:

InvalidParams – If content or embeds are provided.

async get_webhook_message(webhook_id, webhook_token, message_id, thread_id=None)

Get a message from a webhook.

Parameters:
  • webhook_id (int) – The ID of the webhook to get the message from.

  • webhook_token (str) – The token of the webhook to get the message from.

  • message_id (int) – The ID of the message to get.

  • thread_id (id, optional) – The ID of the thread to get the message from, by default None

Returns:

A message object.

Return type:

ClientResponse

async edit_webhook_message(webhook_id, webhook_token, message_id, thread_id=None, content=None, embeds=None, allowed_mentions=None, components=None)

Edit a message from a webhook.

Parameters:
  • webhook_id (int) – The ID of the webhook to edit the message from.

  • webhook_token (str) – The token of the webhook to edit the message from.

  • message_id (int) – The ID of the message to edit.

  • thread_id (int, optional) – ID of the thread the message is in, by default None

  • content (str, optional) – The message contents (up to 2000 characters), by default None

  • embeds (List[dict], optional) – Embedded rich content, by default None

  • allowed_mentions (Any, optional) – Allowed mentions for the message, by default None

  • components (List[Any], optional) – The components to include with the message, by default None

Returns:

A message object.

Return type:

ClientResponse

async delete_webhook_message(webhook_id, webhook_token, message_id)

Delete a message from a webhook.

Parameters:
  • webhook_id (int) – The ID of the webhook to delete the message from.

  • webhook_token (str) – The token of the webhook to delete the message from.

  • message_id (int) – The ID of the message to delete.

Returns:

The response from Discord.

Return type:

ClientResponse