Sha256: b1005e1a139d1e22e262118bd83723055b6f871fcda46f6261376454c6474155
Contents?: true
Size: 718 Bytes
Versions: 2
Compression:
Stored size: 718 Bytes
Contents
# frozen_string_literal: true require "discorb" client = Discorb::Client.new client.once :standby do puts "Logged in as #{client.user}" end client.on :message do |message| next if message.author.bot? next unless message.content == "!quiz" operator = %i[+ - *].sample num1 = rand(1..10) num2 = rand(1..10) val = num1.send(operator, num2) message.channel.post("Quiz: `#{num1} #{operator} #{num2}`") begin msg = client.event_lock(:message, 30) do |m| m.content == val.to_s && m.channel == message.channel end.wait rescue Discorb::TimeoutError message.channel.post("No one answered...") else msg.reply("Correct!") end end client.run(ENV.fetch("DISCORD_BOT_TOKEN", nil))
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
discorb-0.17.1 | examples/simple/wait_for_message.rb |
discorb-0.17.0 | examples/simple/wait_for_message.rb |