Represents a poll.
More...
#include "message.h"
◆ add_answer() [1/4]
◆ add_answer() [2/4]
poll & dpp::poll::add_answer |
( |
const std::string & |
text, |
|
|
const emoji & |
e |
|
) |
| |
Add an answer to this poll.
- Note
- At the time of writing this, a poll can have up to 10 answers
- Parameters
-
text | Text for the answer |
e | Optional emoji |
- Returns
- self for method chaining
◆ add_answer() [3/4]
poll & dpp::poll::add_answer |
( |
const std::string & |
text, |
|
|
const std::string & |
emoji |
|
) |
| |
Add an answer to this poll.
- Note
- At the time of writing this, a poll can have up to 10 answers
- Parameters
-
text | Text for the answer |
emoji | Optional emoji |
- Returns
- self for method chaining
◆ add_answer() [4/4]
poll & dpp::poll::add_answer |
( |
const std::string & |
text, |
|
|
snowflake |
emoji_id = 0 , |
|
|
bool |
is_animated = false |
|
) |
| |
Add an answer to this poll.
- Note
- At the time of writing this, a poll can have up to 10 answers
- Parameters
-
text | Text for the answer |
emoji_id | Optional emoji |
is_animated | Whether the emoji is animated |
- Returns
- self for method chaining
◆ find_answer()
const poll_media * dpp::poll::find_answer |
( |
uint32_t |
id | ) |
const |
|
noexcept |
Helper to find an answer by ID.
- Parameters
-
- Returns
- Pointer to the answer with the matching ID, or nullptr if not found
◆ get_question_text()
const std::string & dpp::poll::get_question_text |
( |
| ) |
const |
|
noexcept |
Helper to get the question text.
- Returns
- question.text
◆ get_vote_count()
std::optional< uint32_t > dpp::poll::get_vote_count |
( |
uint32_t |
answer_id | ) |
const |
|
noexcept |
Helper to find the vote count in the results.
- Parameters
-
answer_id | ID of the answer to find |
- Returns
- std::optional<uint32_t> Optional count of votes. An empty optional means Discord did not send the results, it does not mean 0. It can also mean the poll does not have an answer with this ID
- See also
- https://discord.com/developers/docs/resources/poll#poll-results-object
◆ set_allow_multiselect()
poll & dpp::poll::set_allow_multiselect |
( |
bool |
allow | ) |
|
|
noexcept |
Set the duration of the poll in hours.
- Parameters
-
hours | Duration of the poll in hours |
- Returns
- self for method chaining
◆ set_duration()
poll & dpp::poll::set_duration |
( |
uint32_t |
hours | ) |
|
|
noexcept |
Set the duration of the poll in hours.
- Parameters
-
hours | Duration of the poll in hours, max 7 days (168 hours) at the time of writing |
- Returns
- self for method chaining
◆ set_question()
poll & dpp::poll::set_question |
( |
const std::string & |
text | ) |
|
Set the question for this poll.
- Parameters
-
text | Text for the question |
- Returns
- self for method chaining
◆ allow_multiselect
bool dpp::poll::allow_multiselect {false} |
Whether a user can select multiple answers.
◆ answers
List of answers of the poll.
- Note
- At the time of writing this can contain up to 10 answers
- See also
- answer
◆ expiry
double dpp::poll::expiry {24.0} |
When retriving a poll from the API, this is the timestamp at which the poll will expire.
When creating a poll, this is the number of hours the poll should be up for, up to 7 days (168 hours), and this field will be rounded.
◆ layout_type
◆ question
Poll question.
At the time of writing only the text field is supported by Discord
- See also
- media
◆ results
std::optional<poll_results> dpp::poll::results {std::nullopt} |
The (optional) results of the poll.
This field may or may not be present, and its absence means "unknown results", not "no results".
- Note
- Quote from Discord: "The results field may be not present in certain responses where, as an implementation detail,
we do not fetch the poll results in our backend. This should be treated as "unknown results",
as opposed to "no results". You can keep using the results if you have previously received them through other means."
- See also
- https://discord.com/developers/docs/resources/poll#poll-results-object
The documentation for this struct was generated from the following files: