diff options
| author | Alee <alee14498@gmail.com> | 2018-06-23 18:18:56 -0400 |
|---|---|---|
| committer | Alee <alee14498@gmail.com> | 2018-06-23 18:18:56 -0400 |
| commit | 677fd30db28bd21a72ede46e847c48505c4a9ff8 (patch) | |
| tree | f8819a6d735f369ff06c59dec711743804db046a | |
| parent | ca44ee2b1c54f71757179814ef2f548e7057af5b (diff) | |
| download | AleeBot-677fd30db28bd21a72ede46e847c48505c4a9ff8.tar.gz AleeBot-677fd30db28bd21a72ede46e847c48505c4a9ff8.tar.bz2 AleeBot-677fd30db28bd21a72ede46e847c48505c4a9ff8.zip | |
Added back the economy feature (it's broken for now)
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | bot_discord.js | 1 | ||||
| -rw-r--r-- | commands/balance.js | 48 | ||||
| -rw-r--r-- | commands/daily.js | 54 | ||||
| -rw-r--r-- | package-lock.json | 5 | ||||
| -rw-r--r-- | package.json | 1 |
6 files changed, 110 insertions, 0 deletions
@@ -14,3 +14,4 @@ ffprobe.exe userData.sqlite
.vs/slnx.sqlite .vs/slnx.sqlite-journal +json.sqlite diff --git a/bot_discord.js b/bot_discord.js index 87d9b95..785627b 100644 --- a/bot_discord.js +++ b/bot_discord.js @@ -27,6 +27,7 @@ const client = new Discord.Client({ });
const settings = require('./storage/settings.json')
const fs = require('fs');
+const db = require('quick.db');
const api = require('./tokens.json');
const dbl = new DBL(api.dbltoken, client);
diff --git a/commands/balance.js b/commands/balance.js new file mode 100644 index 0000000..fe3b9f8 --- /dev/null +++ b/commands/balance.js @@ -0,0 +1,48 @@ +/**************************************** + * + * Balance: Command for AleeBot + * Copyright (C) 2018 AleeCorp + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * *************************************/ +module.exports.run = async (client, message) => { + const db = require('quick.db'); + const { RichEmbed } = require('discord.js'); + + let user = message.mentions.users.first() || message.author; + + let balance = await db.fetch(`userBalance_${user.id}`); + + if (balance === null) balance = 0; + const embed = new RichEmbed() + .setDescription(`**AleeCorp Bank**`) + .addField('Account Holder: ', user.username, true) + .addField('Account Balance: ', balance, true) + .setColor('#1fd619') + + message.channel.send({embed}) + }; + + exports.conf = { + aliases: ['bal', 'money'], + guildOnly: false, + }; + exports.help = { + name: 'balance', + description: 'Checks the balance of AleeBot', + usage: 'balance [@someone (optional)]', + category: '- Economy Commands', + }; +
\ No newline at end of file diff --git a/commands/daily.js b/commands/daily.js new file mode 100644 index 0000000..00a9d6c --- /dev/null +++ b/commands/daily.js @@ -0,0 +1,54 @@ +/**************************************** + * + * Daily: Command for AleeBot + * Copyright (C) 2018 AleeCorp + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * *************************************/ +const db = require('quick.db'); + ms = require('parse-ms'); + +module.exports.run = async (client, message) => { + const { RichEmbed } = require('discord.js'); + + let cooldown = 8.64e+7, + amount = 100; + + let lastDaily = await db.fetch(`lastDaily_${message.author.id}`); + + if (lastDaily !== null && cooldown - (Date.now() - lastDaily) > 0) { + let timeObj = ms(cooldown - (Date.now() - lastDaily)); + + message.reply(`You already collected your money, please wait **${timeObj.hours}h ${timeObj.minutes}m**!`) + } else { + message.channel.send(`You have successfully collected $${amount} dollars!`); + + db.set(`lastDaily_${message.author.id}`, Date.now()); + db.add(`userBalance_${message.author.id}`, 100); + } + + }; + + exports.conf = { + aliases: [], + guildOnly: false, + }; + exports.help = { + name: 'daily', + description: 'This gives you money everyday.', + usage: 'daily', + category: '- Economy Commands', + }; +
\ No newline at end of file diff --git a/package-lock.json b/package-lock.json index e8938f3..12e168a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -509,6 +509,11 @@ "resolved": "https://registry.npmjs.org/os/-/os-0.1.1.tgz", "integrity": "sha1-IIhF6J4ZOtTZcUdLk5R3NqVtE/M=" }, + "parse-ms": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-1.0.1.tgz", + "integrity": "sha1-VjRtR0nXjyNDDKDHE4UK75GqNh0=" + }, "parseqs": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz", diff --git a/package.json b/package.json index 4a8807d..2b778c0 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "git-last-commit": "^0.3.0", "moment": "^2.21.0", "os": "^0.1.1", + "parse-ms": "^1.0.1", "quick.db": "^6.3.1", "readline": "^1.3.0" }, |
