Ver Fonte

Polling

Polling
Neiro há 6 anos atrás
pai
commit
1659788e75
2 ficheiros alterados com 30 adições e 1 exclusões
  1. 24 0
      app/responses/poll.rb
  2. 6 1
      bot.rb

+ 24 - 0
app/responses/poll.rb

@@ -0,0 +1,24 @@
+def new_poll_embed(event, options)
+    fields = []
+    optionsArray = options.split(",")
+    name = event.author.nickname || event.author.name
+
+    a = optionsArray.count
+
+    for b in 1..a-1 do            
+        fields.push(name: Emoji::LETTERS[b-1], value: optionsArray[b] + "\n" + CharAppResponses::INLINE_SPACE , inline:true)
+    end
+
+    chat_embed = Embed.new(
+        title:  optionsArray[0],
+        description: "Created by : #{name}",
+        color: event.author.color.combined,
+        fields: fields
+    )
+
+    msg = event.send_embed("", chat_embed)
+
+    for b in 1..a-1 do            
+        msg.react(Emoji::LETTERS[b-1])
+    end
+  end

+ 6 - 1
bot.rb

@@ -135,13 +135,18 @@ app = Command.new(:app, "Everything to do with character applications", opts) do
   end
 end
 
+poll = Command.new(:poll) do |event, options|
+  new_poll_embed(event, options)
+end
+
 # ---
 
 commands = [
   hello,
   matchup,
   app,
-  help
+  help,
+  poll
 ]
 
 # This will trigger on every message sent in discord