DiSky DiSky v5.0.0-b1

Creating polls

guide

Build a poll with its question, answers and duration, then post it alone or on a message.

messagespollsbuilder

This page covers building a poll and sending it: on its own with post or reply with, or attached to a message builder. Reading a poll back, ending it and its vote events are on the polls page. You're assumed to have a bot named "my-bot" logged in and to know how sending messages works.

How a poll is built

creates a poll from its question. Add its answers to , then hand the poll to or like any other content. with and asking work in place of titled.

on message received seen by "my-bot":
    if discord content of event-message is "!lunch":
        set {_poll} to a new poll titled "Where do we eat?"
        add "Pizza", "Burgers" and "Sushi" to poll answer drafts of {_poll}
        post {_poll} to event-channel

A poll is not a builder in the builder sense: it has no build result of, and sending it never needs await. It is checked when it is sent or attached, so a poll with no answer fails on that line, not on the line that created it. The poll that leaves is a copy: editing {_poll} afterwards changes nothing on Discord, and the same poll can be posted twice.

expression new pollPoll Builder[a] new poll (with|titled|asking) [the] [question] %string%Creates a poll builder from its question (300 characters at most). Without an explicit duration it lasts 24 hours. Add at least one answer before sending it.Poll Buildersince 5.0.0-a2

Options

Property

Default

Accepted values

the constructor's question

up to 300 characters

none

1 to 10 answers; set, add, remove

24 hours

from 1 hour to 7 days

false

true: voters may pick several answers

Unlike most builders, these properties read back, so a script can check the poll before sending it.

on message received seen by "my-bot":
    if discord content of event-message is "!vote":
        set {_poll} to a new poll asking "Which features next?"
        add "Music" and "Levels" to poll answer drafts of {_poll}
        set poll duration of {_poll} to 3 days
        set multi answer of {_poll} to true
        reply with "%size of poll answer drafts of {_poll}% options, open for %poll duration of {_poll}%"
        reply with {_poll}

Answers with an emoji

A plain text added to poll answer drafts becomes an answer without emoji. For an emoji, add instead: the emoji is a unicode emoji, an emote, or the <:name:id> form of a custom one.

set {_poll} to a new poll titled "Favorite food?"
add (a new poll answer with text "Pizza" with emoji "🍕") to poll answer drafts of {_poll}
add (a new poll answer with text "Sushi" with emoji "🍣") to poll answer drafts of {_poll}
remove "Pizza" from poll answer drafts of {_poll}

remove matches answers by their text, whether they were added as a text or as an answer object. An answer object can still be changed through and before it is added; once added, the poll holds its own copy.

expression new answerPoll Answer Draft[a] new poll answer [with] [the] (text|content) %string% [with [the] emoji %-emote/string%]Creates a poll answer with an optional emoji, to add to the answers of a poll builder.Poll Answer Draftsince 5.0.0-a2

Polls on a message builder

post and reply with forget the message they send. To keep it, to end the poll later or read its voters, set on a message builder and build it: the poll goes out with the message's content.

on message received seen by "my-bot":
    if discord content of event-message is "!poll-kept":
        set {_poll} to a new poll titled "Ship it?"
        add "Yes" and "No" to poll answer drafts of {_poll}
        set {_m} to a new message with content "Release vote" in event-channel
        set attached poll of {_m} to {_poll}
        await set {_sent} to the build result of {_m}
        set {poll::release} to {_sent}

A message carries one poll at most: setting attached poll again replaces the previous one. A poll cannot share a message with V2 components (containers, sections, text displays).

property attached pollMessage Builder[the] attached poll of %messageaction%The poll of the message being built (a message carries one poll at most; setting it replaces the previous one). The poll is validated and snapshotted when set.Poll Buildersince 5.0.0-a2

Errors you may see

Message (console)

Cause

Fix

a poll needs at least one answer

The poll was sent with an empty poll answer drafts

Add answers before sending

a poll holds at most 10 answers, this one has <n>

Too many answers

Remove some, or split into two polls

a poll lasts between 1 hour and 168 hours (7 days), this one lasts <n> hours

poll duration is out of range

Pick a duration from 1 hour to 7 days

the poll question is <n> characters long, the maximum is 300

The question is too long

Shorten it

the poll answer "..." is <n> characters long, the maximum is 55

An answer is too long

Shorten it

Poll Builder type 5 syntaxes A poll that has not been sent yet: a question, 1 to 10 answers, a duration and whether voters may pick several answers. Send it with 'post' / 'reply with', or attach it to a message builder with 'attached poll of'. It is validated when attached, and the attached poll is a snapshot: editing the builder afterwards changes nothing.
Was this page helpful?
An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.