diff options
| author | Alee <Alee14498@gmail.com> | 2019-10-21 04:53:18 +0000 |
|---|---|---|
| committer | Alee <Alee14498@gmail.com> | 2019-10-21 04:53:18 +0000 |
| commit | b6d9e3305107c221741108a8de7559c9d7f59f14 (patch) | |
| tree | 695881f957dd9071f73c48ad6614499151b02b0a /plugins | |
| parent | 95917207f3ac60f9849dd2010d9a632b480d26db (diff) | |
| download | PokeBot-b6d9e3305107c221741108a8de7559c9d7f59f14.tar.gz PokeBot-b6d9e3305107c221741108a8de7559c9d7f59f14.tar.bz2 PokeBot-b6d9e3305107c221741108a8de7559c9d7f59f14.zip | |
Got economy back + removed outdated help
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/economy.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/plugins/economy.js b/plugins/economy.js new file mode 100644 index 0000000..3658ce8 --- /dev/null +++ b/plugins/economy.js @@ -0,0 +1,40 @@ +/** ************************************** + * + * Economy: Plugin for PokeBot that enables economy features. + * Copyright (C) 2018 TheEdge, jtsshieh, Alee + * + * Licensed under the Open Software License version 3.0 + * + * *************************************/ + +const db = require('quick.db'); +exports.get = async (userid) => { + const amount = await db.fetch(`money_${userid}`); + if (amount) { + return amount; + } + else { + await db.set(`money_${userid}`, 0); + return await db.fetch(`money_${userid}`); + } +}; + +exports.add = async (userid, money) => { + const amount = await db.fetch(`money_${userid}`); + if (amount) { + await db.set(`money_${userid}`, amount + money); + } + else { + await db.set(`money_${userid}`, money); + } +}; + +exports.subtract = async (userid, money) => { + const amount = await db.fetch(`money_${userid}`); + if (amount) { + await db.set(`money_${userid}`, amount - money); + } + else { + await db.set(`money_${userid}`, 0 - money); + } +}; |
