diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-11-12 14:39:15 +0100 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-11-12 14:39:15 +0100 |
commit | 19cd4e7ea97d08d61b5ba650a471bbd2e814d779 (patch) | |
tree | 78aeec5b2be9c5f7519554ad936405c68c40f637 /economy.lua | |
parent | d4da90fada58be5eda399795ffbc82a1365d348b (diff) | |
download | furrybot-19cd4e7ea97d08d61b5ba650a471bbd2e814d779.tar.xz |
Structure overhaul
Diffstat (limited to 'economy.lua')
-rw-r--r-- | economy.lua | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/economy.lua b/economy.lua index 28c9171..e27572b 100644 --- a/economy.lua +++ b/economy.lua @@ -34,28 +34,31 @@ function furrybot.money(money, color) return furrybot.colors.money .. "$" .. money .. color end -function furrybot.commands.money(name, target) - target = target or name - furrybot.ping_message(name, (target == name and "You have " or target .. " has ") .. furrybot.money(furrybot.get_money(target), furrybot.colors.system) .. ".", furrybot.colors.system) -end -furrybot.commands.balance = furrybot.commands.money - -function furrybot.commands.pay(name, target, number) - if furrybot.online_or_error(name, target) then - local money = tonumber(number or "") - if not money or money <= 0 or math.floor(money) ~= money then - furrybot.error_message(name, "Invalid amount of money") - else - if furrybot.take_money(name, money) then - furrybot.add_money(target, money) - furrybot.ping_message(target, name .. " has payed you " .. furrybot.money(money, furrybot.colors.system) .. ".", furrybot.colors.system) +furrybot.commands.money = { + func = function(name, target) + target = target or name + furrybot.ping_message(name, (target == name and "You have " or target .. " has ") .. furrybot.money(furrybot.get_money(target), furrybot.colors.system) .. ".", furrybot.colors.system) + end, +} + +furrybot.commands.pay = { + unsafe = true, + func = function(name, target, number) + if furrybot.online_or_error(name, target) then + local money = tonumber(number or "") + if not money or money <= 0 or math.floor(money) ~= money then + furrybot.error_message(name, "Invalid amount of money") else - furrybot.error_message(name, "You don't have enough money") + if furrybot.take_money(name, money) then + furrybot.add_money(target, money) + furrybot.ping_message(target, name .. " has payed you " .. furrybot.money(money, furrybot.colors.system) .. ".", furrybot.colors.system) + else + furrybot.error_message(name, "You don't have enough money") + end end end - end -end -furrybot.unsafe_commands.pay = true + end, +} return function(_http, _env, _storage) http, env, storage = _http, _env, _storage |