Skip to content

Commit 35815cc

Browse files
committed
add poll docs
1 parent 2104d23 commit 35815cc

File tree

4 files changed

+70
-1
lines changed

4 files changed

+70
-1
lines changed

docs/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* [thumbnail](structure/embed/thumbnail.md)
2121
* [footer](structure/embed/footer.md)
2222
* [timestamp](structure/embed/timestamp.md)
23+
* [poll](structure/poll.md)
2324
* [tts](structure/tts.md)
2425
* [allowed_mentions](structure/allowed_mentions.md)
2526
* [file](structure/file.md)

docs/discord_webhook.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Structure of Webhook
22

3-
Before using Webhooks you have to know the structure. All elements listed here are *optional* but request body should contain `content`, `embeds` or attachments, otherwise request will fail.
3+
Before using Webhooks you have to know the structure. All elements listed here are *optional* but request body should contain `content`, `embeds`, `poll` or attachments, otherwise request will fail.
44

55
* `username` - overrides the predefined username of the webhook
66
* `avatar_url` - overrides the predefined avatar of the webhook
@@ -26,6 +26,17 @@ Before using Webhooks you have to know the structure. All elements listed here a
2626
* `text` - footer text, doesn't support Markdown
2727
* `icon_url` - url of footer icon
2828
* `timestamp` - ISO8601 timestamp (`yyyy-mm-ddThh:mm:ss.msZ`)
29+
* `poll` - poll object
30+
* `question` - poll question object
31+
* `text` - poll question text
32+
* `answers` - array of poll answer objects
33+
* `poll_media` - poll answer object
34+
* `text` - poll answer text
35+
* `emoji` - emoji object (optional)
36+
* `id` - id of emoji (if custom)
37+
* `name` - name of emoji (if built-in)
38+
* `duration` - duration of the poll in hours
39+
* `allow_multiselect` - if true, allows to select multiple answers
2940
* `tts` - makes message to be spoken as with `/tts` command
3041
* `allowed_mentions` - object allowing to control who will be mentioned by message
3142
* `parse` - array, can include next values: `"roles"`, `"users"` and `"everyone"`, depends on which decides which mentions work. If empty, none mention work.

docs/img/structure/poll.png

9 KB
Loading

docs/structure/poll.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# poll
2+
3+
Allows to add poll to message. Poll always has a question (up to 300 characters) with at least 1 answer (up to 10 options total, up to 55 characters per each). Poll duration can be set to value between 1 and 768 hours (32 days), if omitted 24 hours are assumed. Additionally, multiple answers mode is available, but there's no way to limit how many can be selected at time when it's enabled.
4+
5+
Structure can be a bit confusing at first, let's break it down:
6+
7+
* `poll` - poll object
8+
* `question` - poll question object
9+
* `text` - poll question text value, up to 300 characters
10+
* `answers` - array of poll answer objects, up to 10 options can be specified, at least 1 is required
11+
* `poll_media` - poll answer object
12+
* `text` - poll answer text
13+
* `emoji` - emoji object, optional
14+
* `id` - id of emoji, should be provided as string, used when emoji is custom
15+
* `name` - name of emoji, should be written as Unicode character, used when emoji is built-in
16+
* `duration` - duration of the poll in hours (1-768), default is 24 hours
17+
* `allow_multiselect` - if true, allows to select multiple answers, optional, default is false
18+
19+
Example:
20+
21+
```json
22+
{
23+
"poll": {
24+
"question": {
25+
"text": "Cat person or dog person?"
26+
},
27+
"answers": [
28+
{
29+
"poll_media": {
30+
"text": "meow!",
31+
"emoji": {
32+
"name": "🐱"
33+
}
34+
}
35+
},
36+
{
37+
"poll_media": {
38+
"text": "woof!",
39+
"emoji": {
40+
"name": "🐶"
41+
}
42+
}
43+
}
44+
],
45+
"allow_multiselect": true,
46+
"duration": 48
47+
}
48+
}
49+
```
50+
51+
![poll example](../img/structure/poll.png)
52+
53+
## Additional information
54+
55+
By adding `wait=true` to the request query, you can get a response with the message structure, that will include all kind of data about message, including Message ID. Later on it can be used to get poll results using [Get Webhook Message](https://discord.com/developers/docs/resources/webhook#get-webhook-message) request, it allows to see number of votes, but not voters. Additionally there's no way to close poll as it's possible for users and bots (both can only close own polls only).
56+
57+
[Discord API reference](https://discord.com/developers/docs/resources/poll#poll-create-request-object)

0 commit comments

Comments
 (0)