-
-
Save elomatreb/ddb45f84365a26b2948e1232123fa254 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'discordrb' | |
require 'json' | |
require 'whenever' | |
json_id = 1000893 | |
url = "http://www.espncricinfo.com/matches/engine/match/1000893.json" | |
def get_score | |
# This used to be your loop | |
uri = URI(url) | |
response = Net::HTTP.get(uri) | |
hashy = JSON.parse(response) | |
match_data = hashy.fetch("match") | |
sum = match_data.fetch("current_summary") | |
# We don't need to sleep for 15s anymore | |
return sum | |
end | |
#Discord | |
bot = Discordrb::Commands::CommandBot.new token: '', client_id: , prefix: '!' | |
bot.message(with_text: 'Ping!') do |event| | |
event.respond 'Pong!' | |
end | |
bot.command :random do |event, min, max| | |
rand(min.to_i .. max.to_i) | |
end | |
bot.command :score do |event, min, max| | |
# Return the result from our method defined above | |
event.respond get_score() | |
end | |
bot.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment