diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2020-07-23 11:41:02 -0400 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2020-07-23 11:41:02 -0400 |
| commit | ed456ef581c5acd852a924d9cc274a259b2d8ce5 (patch) | |
| tree | 33be62f54239fa6f6b61b9488dbfde329ae1fd78 /deprecated | |
| parent | 1ce861095b2793a1b49546c0adf460fbc2fc5d9f (diff) | |
| download | AleeBot-ed456ef581c5acd852a924d9cc274a259b2d8ce5.tar.gz AleeBot-ed456ef581c5acd852a924d9cc274a259b2d8ce5.tar.bz2 AleeBot-ed456ef581c5acd852a924d9cc274a259b2d8ce5.zip | |
Converted to Discord.JS v12, starting database
Diffstat (limited to 'deprecated')
| -rw-r--r-- | deprecated/balance.js | 50 | ||||
| -rw-r--r-- | deprecated/buy.js | 17 | ||||
| -rw-r--r-- | deprecated/daily.js | 42 | ||||
| -rw-r--r-- | deprecated/pay.js | 60 |
4 files changed, 138 insertions, 31 deletions
diff --git a/deprecated/balance.js b/deprecated/balance.js new file mode 100644 index 0000000..ca32081 --- /dev/null +++ b/deprecated/balance.js @@ -0,0 +1,50 @@ +/** ************************************** + * + * Balance: Command for AleeBot + * Copyright (C) 2017-2020 Alee Productions + * + * 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 {MessageEmbed} = require('discord.js'); + + const user = message.mentions.users.first() || message.author; + + let balance = await db.fetch(`userBalance_${user.id}`); + + if (balance === null) { + db.set(`userBalance_${message.author.id}`, 0); + balance = 0; + } + const embed = new MessageEmbed() + .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', +}; diff --git a/deprecated/buy.js b/deprecated/buy.js index 9757d51..25f2589 100644 --- a/deprecated/buy.js +++ b/deprecated/buy.js @@ -18,7 +18,6 @@ * * *************************************/ module.exports.run = async (client, message, args) => { -/* const Discord = require('discord.js'); const fs = require('fs') const db = require('quick.db'); @@ -39,7 +38,7 @@ const items = JSON.parse(fs.readFileSync('./storage/items.json', 'utf8')); } - const embed = new Discord.RichEmbed() + const embed = new Discord.MessageEmbed() .setDescription(`Available Items`) .setColor('#1fd619') @@ -101,17 +100,15 @@ const items = JSON.parse(fs.readFileSync('./storage/items.json', 'utf8')); } message.channel.send('You bought ' + itemName + '!'); - */ - message.reply('Command is broken for now'); }; exports.conf = { - aliases: [], - guildOnly: false, + aliases: [], + guildOnly: false, }; exports.help = { - name: 'buy', - description: 'Buy things.', - usage: 'buy [item]', - category: '- Economy Commands', + name: 'buy', + description: 'Buy things.', + usage: 'buy [item]', + category: '- Economy Commands', }; diff --git a/deprecated/daily.js b/deprecated/daily.js index c58928c..c0f04f9 100644 --- a/deprecated/daily.js +++ b/deprecated/daily.js @@ -21,36 +21,36 @@ const db = require('quick.db'); ms = require('parse-ms'); module.exports.run = async (client, message) => { - const cooldown = 8.64e+7; - const amount = 100; + const cooldown = 8.64e+7; + const amount = 100; - const lastDaily = await db.fetch(`lastDaily_${message.author.id}`); + const lastDaily = await db.fetch(`lastDaily_${message.author.id}`); - if (lastDaily !== null && cooldown - (Date.now() - lastDaily) > 0) { - const timeObj = ms(cooldown - (Date.now() - lastDaily)); + if (lastDaily !== null && cooldown - (Date.now() - lastDaily) > 0) { + const 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!`); + 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!`); - const balance = await db.fetch(`userBalance_${message.author.id}`); + const balance = await db.fetch(`userBalance_${message.author.id}`); - if (balance == null) { - db.set(`userBalance_${message.author.id}`, 0); - } + if (balance == null) { + db.set(`userBalance_${message.author.id}`, 0); + } - db.set(`lastDaily_${message.author.id}`, Date.now()); - db.add(`userBalance_${message.author.id}`, 100); - } + db.set(`lastDaily_${message.author.id}`, Date.now()); + db.add(`userBalance_${message.author.id}`, 100); + } }; exports.conf = { - aliases: [], - guildOnly: false, + aliases: [], + guildOnly: false, }; exports.help = { - name: 'daily', - description: 'This gives you money everyday.', - usage: 'daily', - category: '- Economy Commands', + name: 'daily', + description: 'This gives you money everyday.', + usage: 'daily', + category: '- Economy Commands', }; diff --git a/deprecated/pay.js b/deprecated/pay.js new file mode 100644 index 0000000..bc27a4b --- /dev/null +++ b/deprecated/pay.js @@ -0,0 +1,60 @@ +/** ************************************** + * + * Pay: Command for AleeBot + * Copyright (C) 2017-2020 Alee Productions + * + * 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, args) => { + const db = require('quick.db'); + if (!message.mentions.members.first()) return message.reply('Please mention a user...'); + + const targetMember = message.mentions.members.first(); + const amount = parseInt(args.join(' ').replace(targetMember, '')); + + if (isNaN(amount)) return message.reply('Please define an amount.'); + + let targetBalance = await db.fetch(`userBalance_${targetMember.id}`); + let selfBalance = await db.fetch(`userBalance_${message.author.id}`); + + if (targetBalance === null) { + db.set(`userBalance_${targetMember.id}`, 0); + targetBalance = 0; + } + + if (selfBalance === null) { + db.set(`userBalance_${message.author.id}`, 0); + selfBalance = 0; + } + + if (amount > selfBalance) return message.reply('Sorry you don\'t have enough money.'); + + db.add(`userBalance_${targetMember.id}`, amount); + db.subtract(`userBalance_${message.author.id}`, amount); + + message.reply(`Successfully transfered $${amount} to ${targetMember.user}`); +}; + +exports.conf = { + aliases: ['transfer'], + guildOnly: false, +}; +exports.help = { + name: 'pay', + description: 'You can pay others!', + usage: 'pay [@user] [interger]', + category: '- Economy Commands', +}; |
