mineral-dart / core

๐Ÿงก The neuralgic heart of the application, this module gathers all the functionalities of the framework.
https://mineral-foundation.org
MIT License
27 stars 8 forks source link

Implementation of polls #145

Closed LeadcodeDev closed 5 months ago

LeadcodeDev commented 5 months ago

Polls introduced to Discord's HTTP API. See more here

Implementation

Proposal

// Constructors
final poll = Poll(
  question: PollQuestion(content: 'What is your favorite programming language ?'),
  answers: [
    PollAnswer(content: 'Dart', emoji: PartialEmoji.fromEmoji(emoji!)),
    PollAnswer(content: 'Java', emoji: PartialEmoji.fromUnicode('๐ŸŽ“')),
    PollAnswer(content: 'Python'),
    PollAnswer(content: 'JavaScript'),
  ],
  expireAt: Duration(days: 6),
  isAllowMultiple: true,
  layout: PollLayout.initial);
// Builder
final poll = PollBuilder()
  .setQuestion(question: 'What is your favorite programming language ?')
  .addAnswer(answer: 'Dart', emoji: PartialEmoji.fromEmoji(emoji!))
  .addAnswer(answer: 'Java', emoji: PartialEmoji.fromUnicode('๐ŸŽ“'))
  .addAnswer(answer: 'Python')
  .addAnswer(answer: 'JavaScript')
  .setExpireAt(Duration(days: 6))
  .allowMultipleResponses(true)
  .setLayout(PollLayout.initial)
  .build();