# 🪝 Discord Webhooks

> **Info:**
Everything on this page can be changed in **Editor > Settings > Discord Webhooks**, or in discord.yml followed by `/pshop reload`.

## Discord Webhooks

Phoenix Shop can post what happens in your shops to Discord: purchases, sales, chest shop trades, Auction House activity, price changes, stock running out, restock alerts, admin edits and a daily summary. Each kind of message can have its own webhook, so each can go to a different channel, or they can all share the default webhook. This is a Premium feature.

<figure><img src="../.gitbook/assets/discord-webhooks/discord-webhooks.png" alt="" width="563"><figcaption><p>Settings (Discord Webhooks)</p></figcaption></figure>

Messages are queued and sent in the background, so a slow or unreachable Discord never holds up a purchase.

## Setup

### Create the webhook

In Discord, open **Server Settings > Integrations > Webhooks**, create one for the channel you want the messages in, and copy its URL.

### Set it in the editor

Paste the URL into **Default Webhook** to use it for every message, or into the **Webhook URL** of one message to send that one somewhere else. Then turn on each message you want.

<figure><img src="../.gitbook/assets/discord-webhooks/default-webhook.png" alt="" width="563"><figcaption><p>Discord Webhooks (Default Webhook)</p></figcaption></figure>

### Test it

**Send Test** in a message's screen posts a test message to its webhook. `/pshop webhooktest` does the same for the `anomaly` message and needs the `phoenixshop.admin` permission.

<figure><img src="../.gitbook/assets/discord-webhooks/send-test.png" alt="" width="563"><figcaption><p>Purchases (Send Test)</p></figcaption></figure>

## Messages

| Message | Posted when | Shows |
| --- | --- | --- |
| purchase | A player buys from a shop. | Player, item, amount, price, currency and shop. |
| sale | A player sells to a shop. | Player, item, amount, price, currency and shop. |
| large-transaction | A purchase or sale costs or pays at least the threshold. | The same, plus whether it was a purchase or a sale. |
| price-change | The [price audit](price-audit.md) or the [price generator](price-generator.md) changes a price. | Shop, item, and the old and new price. |
| stock-depleted | An item with limited stock sells out. | Shop and item. |
| restock | An item with limited stock is restocked. | Shop, item and the new stock. |
| restock-alert | A [restock alert](restock-and-sale-alerts.md#restock-alerts) goes out. | Shop, item, whether it restocked or its sale window opened, and how many players were alerted. |
| player-shop-created | A player builds a chest shop. | Owner, item, mode, prices, currency and location. |
| player-shop-removed | A chest shop is removed. | Owner, item, mode, prices, currency and location. |
| chest-shop-trade | A player buys from or sells to a chest shop. | Customer, owner, whether they bought or sold, item, amount, price and location. |
| auction-listed | An item is listed on the [Auction House](auction-house.md). | Seller, item, price or starting bid, type and duration. |
| auction-sold | A listing sells or an auction is won. | Seller, buyer, item, price and type. |
| auction-bid | A player bids on an auction. | Bidder, seller, item, bid and number of bids. |
| auction-expired | A listing ends without selling. | Seller, item and price. |
| auction-removed | Staff take down a listing. | Staff member, seller and item. |
| auction-restocked | The server restocks the Auction House. | The number of new listings. |
| booster-started | A [sell booster](../add-ons/sell-boosters/README.md) for everyone starts. | Multiplier, what it applies to, duration and who started it. |
| booster-ended | A sell booster for everyone runs out. | Multiplier and what it applied to. |
| admin-edit | An admin changes anything in the editor. | Admin, shop, category, item, what changed and the new value. |
| daily-summary | Once a day, at the set time. | See below. |
| anomaly | `/pshop webhooktest` is run. | Who sent the test. |

<figure><img src="../.gitbook/assets/discord-webhooks/purchases.png" alt="" width="563"><figcaption><p>Discord Webhooks (Purchases)</p></figcaption></figure>

The large transaction message is posted as well as the purchase or sale message, not instead of it. The restock alert message is posted even when no player was alerted.

## Options

Every message has the same options, with a few extras.

<figure><img src="../.gitbook/assets/discord-webhooks/webhook-url.png" alt="" width="563"><figcaption><p>Purchases (Webhook URL)</p></figcaption></figure>

<figure><img src="../.gitbook/assets/discord-webhooks/embed-color.png" alt="" width="563"><figcaption><p>Purchases (Embed Color)</p></figcaption></figure>

<figure><img src="../.gitbook/assets/discord-webhooks/threshold.png" alt="" width="563"><figcaption><p>Large Transactions (Threshold)</p></figcaption></figure>

```yaml
discord:
  default-webhook-url: ''
  purchase:
    enabled: false
    webhook-url: ''
    username: Phoenix Shop
    avatar-url: ''
    embed:
      title: Purchase
      color: '#57f287'
  large-transaction:
    threshold: 10000
  chest-shop-trade:
    minimum-price: 0
  daily-summary:
    time: '00:00'
  restock-alert:
    message:
      restocked: '%item% is back in stock in %shop%.'
      window-opened: '%item% is on sale again in %shop%.'
```

| Option | Description |
| --- | --- |
| default-webhook-url | The webhook every message uses when it has no `webhook-url` of its own. Each message still has to be enabled. |
| enabled | Whether this message is posted at all. |
| webhook-url | The Discord webhook URL. Empty uses `default-webhook-url`; nothing is posted while both are empty. |
| username | The name the webhook posts under. |
| avatar-url | An image URL used as the webhook's avatar. Empty uses the webhook's own. |
| embed.title | The embed's heading. Empty uses the message's default title. |
| embed.color | The colour of the embed's side bar, as a hex value. |
| threshold | Large transaction only. The price at which a purchase or sale counts as large, in any currency. |
| minimum-price | Chest shop trade, auction listed, auction sold and auction bid only. Cheaper trades, listings and bids are not posted, so a busy server does not flood the channel. `0` posts everything. Trades paid in items are always posted. |
| time | Daily summary only. The time of day to post, as `HH:MM` on the server's clock. |
| message | Restock alert only. The text posted when the item restocks, and when it goes on sale again. `%item%` and `%shop%` are filled in. |

## Daily Summary

Posted once a day at the set time, covering the 24 hours before it: the number of purchases and sales, what players spent and were paid per currency, the most traded item, and the player who bought and the player who sold the most. Undone transactions are left out. A day with no transactions says so.

A time the plugin cannot read switches the summary off and leaves a warning in the console.

## Troubleshooting

If messages are not arriving, check the console. The plugin warns once per webhook, without printing the URL, when Discord refuses a post or cannot be reached.

* **The URL is wrong.** It must be the full `https://discord.com/api/webhooks/...` address, not a link to the channel.
* **The webhook was deleted in Discord.** The plugin keeps posting to an address that no longer exists until the URL is changed.
* **Rate limits.** When Discord asks the plugin to slow down, it waits and sends the rest after. Up to 64 messages wait in the queue, and anything past that is dropped, so a very busy shop with purchase, sale or chest shop trade messages on can lose some.

Source: https://www.phoenixplugins.com/docs/phoenix-shop/features/discord-webhooks