# Webhooks

Source: https://righteousbot.dev/docs/features/webhooks/

Create a webhook in a channel and send messages through it under a name and avatar you choose.

A webhook is a channel's own posting slot: a message sent through it arrives under any name and avatar
you pick, like "Server News" instead of Righteous. `,webhooks` creates one and sends
[embed codes](/docs/features/embed-codes/) through it. Every subcommand needs **Manage Server** and
**Manage Webhooks** from you and **Manage Webhooks** from the bot. None of it is premium.

[`,log webhook`](/commands/server-tools/log/#log-webhook) is a separate setting with a webhook of its
own. The two never share one. See [Logging](/docs/features/logging/).

## Create a webhook [#create-a-webhook]

[`,webhooks create`](/commands/server-tools/webhooks/#webhooks-create) makes it in the channel you run
it in, and every message sent through it lands there.

<CommandBlock syntax=",webhooks create <name>" example=",webhooks create Server News" />

The name can have spaces; the first 25 characters are kept, and Discord refuses the word "discord" or
a sixteenth webhook in one channel (nothing is created). It starts with your server icon as its
avatar. **Copy the identifier in the reply**: `send`, `edit` and `delete` all need it.

The channel is recorded once. If someone moves the webhook in Discord's **Integrations** settings,
sends follow it but `list` keeps the old channel.

## Find a lost identifier [#find-a-lost-identifier]

The identifier is the webhook's Discord ID, a long run of digits, not its name.

<CommandBlock syntax=",webhooks list" />

[`,webhooks list`](/commands/server-tools/webhooks/#webhooks-list) shows every webhook this command
made here (identifier, channel, creator), ten to a page. One you made in Discord's own settings, or
another bot's, isn't listed and can't be driven from here.

## Send a message through it [#send-a-message-through-it]

[`,webhooks send`](/commands/server-tools/webhooks/#webhooks-send) takes the identifier and an embed
code. Plain text works as itself.

<CommandBlock syntax=",webhooks send <identifier> <code>" example=",webhooks send 1234567890123456789 {color: #fb4868}$p{title: Maintenance tonight}$p{description: The server goes quiet at 22:00 and comes back within the hour.}$p{footer: {guild.name} && {guild.icon}}$p{button: Status page && https://example.com/status}" />

<EmbedPreview poster="Server News" code="{color: #fb4868}$p{title: Maintenance tonight}$p{description: The server goes quiet at 22:00 and comes back within the hour.}$p{footer: {guild.name} && {guild.icon}}$p{button: Status page && https://example.com/status}" caption="The announcement arriving through a webhook named Server News, not under Righteous." />

The message posts in the webhook's channel, not necessarily where you typed. The bot reacts to your
command with a checkmark instead of replying. Variables fill in from **you**: `{user}` is whoever ran
the command and `{channel.name}` is the channel you ran it in, so write announcements, not greetings.
`{guild.name}` and `{guild.icon}` are the safe pair.

To clear the message later, end the code with `++delete <seconds>` (whole seconds, 1 to 600, at the
very end; a larger number is dropped with the flag and the message stays):

<CommandBlock syntax=",webhooks send <identifier> <code> ++delete <seconds>" example=",webhooks send 1234567890123456789 {content: Voice chat is open, come say hello.} ++delete 600" />

<EmbedPreview poster="Server News" code="{content: Voice chat is open, come say hello.} ++delete 600" caption="The notice as it posts. The drawing leaves out ++delete 600, which removes it ten minutes later." />

<Callout type="error" title="A {v2:} code is refused">
  A webhook can only send classic embeds and link buttons. Use `{title:}`, `{description:}` and
  `{field:}`, or post with [`,customembed`](/commands/server-tools/customembed/#customembed-create).
</Callout>

<Callout type="warn" title="Only link buttons survive the send">
  A webhook can't send a colored button. The bot resends the message without any buttons: your text
  and embed arrive, the buttons quietly don't. `{button: Label && https://example.com}` always goes
  through.
</Callout>

## Change the name and avatar [#change-the-name-and-avatar]

[`,webhooks edit`](/commands/server-tools/webhooks/#webhooks-edit) changes what your members see. Both
settings are read on every send, so a change applies to the next message.

<CommandBlock syntax=",webhooks edit <identifier> <name|pfp> <set|reset> [value]" example=",webhooks edit 1234567890123456789 name set Server News" />

| Setting           | Accepts                                               | After `reset`      |
| ----------------- | ----------------------------------------------------- | ------------------ |
| `name set <name>` | text, first 25 characters kept                        | your server's name |
| `pfp set <image>` | an image attached to the command, or one `https` link | your server's icon |

`pfp` also answers to `profile` and `icon`, `name` to `username`. **On slash only the link works**,
because `/webhooks edit` can't receive a file.

## Delete a webhook [#delete-a-webhook]

[`,webhooks delete`](/commands/server-tools/webhooks/#webhooks-delete) removes it on Discord and drops
the stored entry. Messages it already sent stay.

<CommandBlock syntax=",webhooks delete <identifier>" example=",webhooks delete 1234567890123456789" />

If the channel or webhook was deleted in Discord, Righteous isn't told: run `delete` anyway to clear
the entry. The reply says which of the two it found.

## Common issues [#common-issues]

**`,webhooks` alone did nothing.** It's a set of subcommands: `create`, `list`, `send`, `edit`,
`delete`. Each also has a slash form, and `/webhooks send` collects the code in a pop-up.

**It says the webhook is invalid.** Wrong identifier, or a webhook this command didn't make. Copy the
digits from `,webhooks list`.

**It says the embed is invalid.** Your code rendered nothing Discord accepts, usually every tag
misspelled. Send a bare `{description: test}` and build back up.

**It reports an error sending.** The webhook probably no longer exists (removed from **Integrations**
or its channel deleted): create a new one. If a fresh one fails too, Discord rejected the code's
content, such as a `{description:}` over 4096 characters or an unreachable `{image:}`.

**It posted in the wrong channel.** It posts in the webhook's own channel. `,webhooks` can't move it,
so check **Integrations** or make a second webhook.

**My buttons never showed up.** Only link buttons go through a webhook. Give the button a URL.

**`pfp set` keeps asking for an image.** It wants an attached image or one `https` link with nothing
after it, not a filename or an `http` link.

**It posts under the server's name.** No name is set, or it was reset. Use `name set`.
