poll.rb 604 B

123456789101112131415161718192021222324
  1. def new_poll_embed(event, question, options)
  2. fields = []
  3. name = event.author.nickname || event.author.name
  4. options.map.with_index do |option, index|
  5. fields.push({
  6. name: "#{Emoji::LETTERS[index]} #{option}",
  7. value: CharApp::INLINE_SPACE, inline: true
  8. })
  9. end
  10. chat_embed = Embed.new(
  11. title: question,
  12. description: "Created by : #{name}",
  13. fields: fields
  14. )
  15. chat_embed.color = event.author.color.combined
  16. poll = event.send_embed("", chat_embed)
  17. options.each.with_index do |_, index|
  18. poll.react(Emoji::LETTERS[index])
  19. end
  20. end