fix scoreboard missing variable for get_coin_count

This commit is contained in:
mud mud 2022-10-11 14:45:15 +02:00
parent 3b2586bac1
commit 55ebc9856c
Signed by untrusted user: mud
GPG Key ID: D29C9385CC54F61C

View File

@ -26,7 +26,8 @@ def load_scoreboard()
YAML::load_file(SCOREBOARD) || {} YAML::load_file(SCOREBOARD) || {}
end end
def get_coin_count(scoreboard, user) def get_coin_count(user)
scoreboard = load_scoreboard()
scoreboard[user] || 0 scoreboard[user] || 0
end end
@ -64,7 +65,7 @@ bot.message(content: 'GET COIN' ) do |event|
coin_state_active = false 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!" event.respond "Nice catch, #{event.author.display_name}! You have #{plural('coin', coins)} now!"
else else
event.respond "No coins for you, #{event.author.display_name}!" event.respond "No coins for you, #{event.author.display_name}!"
@ -72,7 +73,7 @@ bot.message(content: 'GET COIN' ) do |event|
end end
bot.message(with_text: '/coins') do |event| 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)}!" event.respond "#{event.author.display_name}, you have #{plural('coin', coins)}!"
end end