poll.rb 674 B

12345678910111213141516171819202122232425262728
  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,
  8. inline: true
  9. })
  10. end
  11. chat_embed = Embed.new(
  12. title: question,
  13. author: {
  14. name: name,
  15. icon_url: event.author.avatar_url
  16. },
  17. fields: fields
  18. )
  19. chat_embed.color = event.author.color.combined if event.author.color
  20. poll = event.send_embed("", chat_embed)
  21. options.each.with_index do |_, index|
  22. poll.react(Emoji::LETTERS[index])
  23. end
  24. end