From 55ebc9856c4353f04d1aae78227f44fef384c573 Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 11 Oct 2022 14:45:15 +0200 Subject: [PATCH] fix scoreboard missing variable for get_coin_count --- coin.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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