diff options
| author | Alee <alee14498@gmail.com> | 2018-03-29 19:42:42 -0400 |
|---|---|---|
| committer | Alee <alee14498@gmail.com> | 2018-03-29 19:42:42 -0400 |
| commit | 784b6fc90f16af6f69f14b9415f82dc5429b2485 (patch) | |
| tree | de2e68cedc6b3b22d61fdaedd290563115117a7e /commands | |
| parent | 4bfdff40646c653f2c391a79f82ea2c85645ecb3 (diff) | |
| download | AleeBot-784b6fc90f16af6f69f14b9415f82dc5429b2485.tar.gz AleeBot-784b6fc90f16af6f69f14b9415f82dc5429b2485.tar.bz2 AleeBot-784b6fc90f16af6f69f14b9415f82dc5429b2485.zip | |
Wheeeee new buy command!!!!!
Diffstat (limited to 'commands')
| -rw-r--r-- | commands/buy.js | 124 | ||||
| -rw-r--r-- | commands/changelog.js | 9 | ||||
| -rw-r--r-- | commands/help.js | 2 |
3 files changed, 128 insertions, 7 deletions
diff --git a/commands/buy.js b/commands/buy.js new file mode 100644 index 0000000..89422ad --- /dev/null +++ b/commands/buy.js @@ -0,0 +1,124 @@ +/******************************** + * + * Buy: Command for AleeBot + * + * Copyright (c) 2018 AleeCorp + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + ********************************/ +module.exports.run = async (client, message, args) => { + const economy = require('discord-eco') + const Discord = require('discord.js'); + const fs = require('fs') + const items = JSON.parse(fs.readFileSync('./items.json', 'utf8')); + + let categories = []; + + if (!args.join(" ")) { + + + for (var i in items) { + + + if (!categories.includes(items[i].type)) { + categories.push(items[i].type) + } + + } + + + const embed = new Discord.RichEmbed() + .setDescription(`Available Items`) + .setColor('#1fd619') + + for (var i = 0; i < categories.length; i++) { + + var tempDesc = ''; + + for (var c in items) { + if (categories[i] === items[c].type) { + + tempDesc += `${items[c].name} - $${items[c].price} - ${items[c].desc}\n`; + + } + + } + + embed.addField(categories[i], tempDesc); + + } + + + return message.channel.send({ + embed + }); + + + } + + let itemName = ''; + let itemPrice = 0; + let itemDesc = ''; + + for (var i in items) { + if (args.join(" ").trim().toUpperCase() === items[i].name.toUpperCase()) { + itemName = items[i].name; + itemPrice = items[i].price; + itemDesc = items[i].desc; + } + } + + + if (itemName === '') { + return message.channel.send(`Item ${args.join(" ").trim()} not found.`) + } + + + economy.fetchBalance(message.author.id + message.guild.id).then((i) => { + if (i.money <= itemPrice) { + + return message.channel.send(`You don't have enough money for this item.`); + } + + economy.updateBalance(message.author.id + message.guild.id, parseInt(`-${itemPrice}`)).then((i) => { + + message.channel.send('You bought ' + itemName + '!'); + + + if (itemName === 'Programmer Role') { + message.guild.members.get(message.author.id).addRole(message.guild.roles.find("name", "Programmers")); + } + + }) + + }) + + }; + + exports.conf = { + aliases: [], + guildOnly: false, + }; + exports.help = { + name: 'buy', + description: 'Buy things.', + usage: 'buy [item]', + category: '- Economy Commands', + }; +
\ No newline at end of file diff --git a/commands/changelog.js b/commands/changelog.js index 8b5f70a..faf4aaa 100644 --- a/commands/changelog.js +++ b/commands/changelog.js @@ -25,12 +25,9 @@ module.exports.run = async (client, message) => {
const Discord = require('discord.js');
const embed = new Discord.RichEmbed()
- .setAuthor('AleeBot ' + '2.4.0 ' + 'Changelog', 'https://cdn.discordapp.com/avatars/282547024547545109/6c147a444ae328c38145ef1f74169e38.png?size=2048')
- .setDescription('What\'s new in AleeBot 2.4?')
- .addField('[>] Suggestion Command!','Suggest command is only for exclusive servers!', true)
- .addField('[>] Ban and kick reasons!','Now you can ban and kick people within reasons!', true)
- .addField('[>] Economy!','Yes, it\'s true we\'ve now added economy in AleeBot but for now you can check for your balance!', true)
- .setFooter('AleeCorp Copyright 2017')
+ .setAuthor('AleeBot ' + '2.5.0 Beta ' + 'Changelog', 'https://cdn.discordapp.com/avatars/282547024547545109/6c147a444ae328c38145ef1f74169e38.png?size=2048')
+ .setDescription('What\'s new in AleeBot 2.5?')
+ .addField('[>] Buy Command!','Now you could buy things!', true)
.setColor('#1fd619');
message.channel.sendEmbed(embed);
diff --git a/commands/help.js b/commands/help.js index 6634e68..de59c3e 100644 --- a/commands/help.js +++ b/commands/help.js @@ -35,7 +35,7 @@ module.exports.run = async (client, message) => { const embed = new Discord.RichEmbed()
.setTitle('AleeBot Help')
- .setAuthor('AleeBot 2.4.0' + ` Help and on ${client.guilds.size} servers`, 'https://cdn.discordapp.com/avatars/282547024547545109/6c147a444ae328c38145ef1f74169e38.png?size=2048')
+ .setAuthor('AleeBot 2.5.0 Beta' + ` Help and on ${client.guilds.size} servers`, 'https://cdn.discordapp.com/avatars/282547024547545109/6c147a444ae328c38145ef1f74169e38.png?size=2048')
.setDescription('Every command you input into AleeBot is `' + require('../absettings.json').prefix + '`')
.setColor('#1fd619')
.setFooter('AleeCorp Copyright 2018');
|
