Skip to main content

Poll

Trait Poll 

Source
pub trait Poll: Send + Sync {
    // Required methods
    fn title(&self) -> String;
    fn description(&self) -> String;
    fn duration(&self) -> u64;
    fn on_complete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: &'life1 Context,
        message_id: u64,
        yes_votes: u32,
        no_votes: u32,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn yes_reaction(&self) -> ReactionType { ... }
    fn no_reaction(&self) -> ReactionType { ... }
    fn build_embed(&self) -> CreateEmbed { ... }
    fn start<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        ctx: &'life1 Context,
        command: &'life2 CommandInteraction,
    ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}
Expand description

Trait for reaction-based polls.

Required Methods§

Source

fn title(&self) -> String

The poll title displayed in the embed.

Source

fn description(&self) -> String

The poll description/question.

Source

fn duration(&self) -> u64

Duration of the poll in seconds.

Source

fn on_complete<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 Context, message_id: u64, yes_votes: u32, no_votes: u32, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called when the poll ends with results. yes_votes and no_votes are counts excluding the bot.

Provided Methods§

Source

fn yes_reaction(&self) -> ReactionType

The yes/positive reaction emoji.

Source

fn no_reaction(&self) -> ReactionType

The no/negative reaction emoji.

Source

fn build_embed(&self) -> CreateEmbed

Build the embed shown for the poll.

Source

fn start<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ctx: &'life1 Context, command: &'life2 CommandInteraction, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Start the poll by sending the embed and adding reactions. Returns the message ID of the created poll.

Implementors§