poll.rb 632 B

123456789101112131415161718192021
  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({ name: "#{Emoji::LETTERS[index]} #{option}", value: CharAppResponses::INLINE_SPACE, inline: true })
  6. end
  7. chat_embed = Embed.new(
  8. title: question,
  9. description: "Created by : #{name}",
  10. fields: fields
  11. )
  12. chat_embed.color = event.author.color.combined
  13. poll = event.send_embed("", chat_embed)
  14. options.each.with_index do |_, index|
  15. poll.react(Emoji::LETTERS[index])
  16. end
  17. end