Class: Discordrb::Poll::Builder
- Inherits:
-
Object
- Object
- Discordrb::Poll::Builder
- Defined in:
- lib/discordrb/data/poll.rb
Overview
Builder for polls.
Instance Method Summary collapse
-
#answer(text:, emoji: nil) ⇒ void
(also: #add_answer)
Add an answer to the poll builder.
-
#initialize(question:, layout: :default, duration: 24, multiselect: false) ⇒ Builder
constructor
Create a poll request object.
Constructor Details
#initialize(question:, layout: :default, duration: 24, multiselect: false) ⇒ Builder
Create a poll request object.
333 334 335 336 337 338 339 |
# File 'lib/discordrb/data/poll.rb', line 333 def initialize(question:, layout: :default, duration: 24, multiselect: false) @layout = layout @answers = [] @question = question @duration = duration || 24 @multiselect = multiselect end |
Instance Method Details
#answer(text:, emoji: nil) ⇒ void Also known as: add_answer
This method returns an undefined value.
Add an answer to the poll builder.
345 346 347 348 349 |
# File 'lib/discordrb/data/poll.rb', line 345 def answer(text:, emoji: nil) emoji = Emoji.build_emoji_hash(emoji, prefix: false) if emoji @answers << { poll_media: { text: text, emoji: emoji }.compact } end |