Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Ruboty
- module Handlers
- class Ping < Base
- on(
- /(\d*)d(\d+) *(\+ *(\d+))?\z/i,
- name: "roll",
- description: "Roll dice"
- )
- def roll(message)
- count = message.match_data[1].to_i
- count = 1 if count.zero?
- surface = message.match_data[2].to_i
- additional = message.match_data[4]&.to_i
- rolls = count.times.map { rand(surface) + 1}
- rolls << additional if additional
- message.reply ":game_die: #{rolls.sum} (#{rolls.join(' + ')})"
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement