You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Message are pieces of text that can be sent to players, if required with clickable options for
4
+
the player to interact with.
5
+
6
+
7
+
## Table of Contents
8
+
1.[Format](#format)
9
+
1.[Responses](#responses)
10
+
11
+
12
+
<aname="format"></a>
13
+
## Format
14
+
15
+
You must send a `POST` request to the `/message` endpoint.
16
+
The body of the request must have the following format:
17
+
18
+
```json
19
+
{
20
+
"id": "unique-id",
21
+
"target": "player-uuid",
22
+
"targets": [ "player-1-uuid", "player-2-uuid"],
23
+
"message": "Hello world! Testing the Web-API messages :D",
24
+
"once": true,
25
+
"options": [{
26
+
"key": "option1",
27
+
"value": "Option 1"
28
+
}, {
29
+
"key": "other_opt",
30
+
"value": "[Other Option]"
31
+
}]
32
+
}
33
+
```
34
+
35
+
The `id` is a unique identifier that the Web-API will send back to your server. You can use
36
+
this to identify different messages. You can put anything you like here, or leave it blank
37
+
in case you don't need it.
38
+
39
+
The `target` is the UUID of the player you wish to send the message to. Sending messages
40
+
to offline players is not possible. If you want to send a message to multiple players use
41
+
the `targets` array, which is an array of UUIDs. You must specify either `target` or `targets`.
42
+
43
+
`message` is the content of your message - the actual text sent to the player in chat.
44
+
You can use the [Ampersand formatting](https://docs.spongepowered.org/stable/en-GB/plugin/text/representations/formatting-code-legacy.html#ampersand-formatting)
45
+
to apply text formatting to the message. Your message must have a message...
46
+
47
+
If the `once` option is set to true then the player will only be able to reply to the message
48
+
once (assuming it has clickable options). Otherwise, if missing or set to false, the player will
49
+
be able to click the provided options multiple times.
50
+
51
+
The `options` array contains all the clickable options the player can choose from.
52
+
Each option has a `key` and a `value`. The `key` is used internally, and sent back to your
53
+
server if the player clicks that option. The `value` is what is displayed to the player
54
+
in the text.
55
+
56
+
57
+
<aname="responses"></a>
58
+
## Responses
59
+
60
+
To receive the responses (when players click one of the provided options) you must add a
61
+
[WebHook](WEBHOOKS.md) for **CUSTOM_MESSAGE**.
62
+
63
+
The response will look similar to the following:
64
+
```json
65
+
{
66
+
"id": "your_id",
67
+
"source": "The UUID of the player that selected this response",
68
+
"choice": "The key of the option that the player selected"
69
+
}
70
+
```
71
+
72
+
The `id` is the id that you specified when sending the message as described above.
73
+
74
+
The `source` is the UUID of the player that clicked on the option.
75
+
76
+
The `choice` is the **key** of the option that the player clicked on.
0 commit comments