dpp::poll
message.h
bool bool dpp::poll::allow_multiselect allow_multiselect dpp::poll::allow_multiselect {false}

Whether a user can select multiple answers.

std::map< uint32_t, poll_answer > std::map<uint32_t, poll_answer> dpp::poll::answers answers dpp::poll::answers {}

List of answers of the poll.

At the time of writing this can contain up to 10 answers

answer

double double dpp::poll::expiry expiry 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.

poll_layout_type poll_layout_type dpp::poll::layout_type layout_type dpp::poll::layout_type {pl_default}

Layout type of the poll. Defaults to, well, pl_default.

poll_layout_type

poll_media poll_media dpp::poll::question question dpp::poll::question {}

Poll question. At the time of writing only the text field is supported by Discord.

media

std::optional< poll_results > std::optional<poll_results> dpp::poll::results 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".

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."

https://discord.com/developers/docs/resources/poll#poll-results-object

poll & poll & dpp::poll::add_answer (const poll_media &media) add_answer dpp::poll::add_answer const poll_media & media

Add an answer to this poll.

At the time of writing this, a poll can have up to 10 answers

media

Data of the answer

self for method chaining

poll & poll & dpp::poll::add_answer (std::string_view text, const emoji &e) add_answer dpp::poll::add_answer std::string_view text const emoji & e

Add an answer to this poll.

At the time of writing this, a poll can have up to 10 answers

text

Text for the answer

e

Optional emoji

self for method chaining

poll & poll & dpp::poll::add_answer (std::string_view text, snowflake emoji_id=0, bool is_animated=false) add_answer dpp::poll::add_answer std::string_view text snowflake emoji_id 0 bool is_animated false

Add an answer to this poll.

At the time of writing this, a poll can have up to 10 answers

text

Text for the answer

emoji_id

Optional emoji

is_animated

Whether the emoji is animated

self for method chaining

poll & poll & dpp::poll::add_answer (std::string_view text, std::string_view emoji) add_answer dpp::poll::add_answer std::string_view text std::string_view emoji

Add an answer to this poll.

At the time of writing this, a poll can have up to 10 answers

text

Text for the answer

emoji

Optional emoji

self for method chaining

const poll_media * const poll_media * dpp::poll::find_answer (uint32_t id) const noexcept find_answer dpp::poll::find_answer uint32_t id

Helper to find an answer by ID.

id

ID to find

Pointer to the answer with the matching ID, or nullptr if not found

const std::string & const std::string & dpp::poll::get_question_text () const noexcept get_question_text dpp::poll::get_question_text

Helper to get the question text.

question.text

std::optional< uint32_t > std::optional< uint32_t > dpp::poll::get_vote_count (uint32_t answer_id) const noexcept get_vote_count dpp::poll::get_vote_count uint32_t answer_id

Helper to find the vote count in the results.

answer_id

ID of the answer to find

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

https://discord.com/developers/docs/resources/poll#poll-results-object

poll & poll & dpp::poll::set_allow_multiselect (bool allow) noexcept set_allow_multiselect dpp::poll::set_allow_multiselect bool allow

Set if the poll should allow multi-selecting.

allow

Should allow multi-select?

self for method chaining

poll & poll & dpp::poll::set_duration (uint32_t hours) noexcept set_duration dpp::poll::set_duration uint32_t hours

Set the duration of the poll in hours.

hours

Duration of the poll in hours, max 7 days (168 hours) at the time of writing

self for method chaining

poll & poll & dpp::poll::set_question (std::string_view text) set_question dpp::poll::set_question std::string_view text

Set the question for this poll.

text

Text for the question

self for method chaining

Represents a poll.

https://discord.com/developers/docs/resources/poll

K
T
bool
double
dpp::partial_emoji
name
id
animated
dpp::poll
question
answers
expiry
allow_multiselect
layout_type
results
dpp::poll_answer
id
media
dpp::poll_media
text
emoji
dpp::snowflake
value
poll_layout_type
std::basic_string< Char >
std::map< K, T >
keys
elements
std::map< uint32_t, dpp::poll_answer >
keys
elements
< uint32_t, dpp::poll_answer >
optional< dpp::poll_results >
std::string
uint32_t
uint64_t
- dpp::poll
  add_answer
- dpp::poll
  add_answer
- dpp::poll
  add_answer
- dpp::poll
  add_answer
- dpp::poll
  allow_multiselect
- dpp::poll
  answers
- dpp::poll
  expiry
- dpp::poll
  find_answer
- dpp::poll
  get_question_text
- dpp::poll
  get_vote_count
- dpp::poll
  layout_type
- dpp::poll
  question
- dpp::poll
  results
- dpp::poll
  set_allow_multiselect
- dpp::poll
  set_duration
- dpp::poll
  set_question