diff --git a/coin.rb b/coin.rb index 5f0fd83..60b40c5 100644 --- a/coin.rb +++ b/coin.rb @@ -26,7 +26,8 @@ def load_scoreboard() YAML::load_file(SCOREBOARD) || {} end -def get_coin_count(scoreboard, user) +def get_coin_count(user) + scoreboard = load_scoreboard() scoreboard[user] || 0 end @@ -64,7 +65,7 @@ bot.message(content: 'GET COIN' ) do |event| coin_state_active = false - coins = get_coin_count(scoreboard, event.author.id) + coins = get_coin_count(event.author.id) event.respond "Nice catch, #{event.author.display_name}! You have #{plural('coin', coins)} now!" else event.respond "No coins for you, #{event.author.display_name}!" @@ -72,7 +73,7 @@ bot.message(content: 'GET COIN' ) do |event| end bot.message(with_text: '/coins') do |event| - coins = get_coin_count(load_scoreboard(), event.author.id) + coins = get_coin_count(event.author.id) event.respond "#{event.author.display_name}, you have #{plural('coin', coins)}!" end