Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*jshint esversion: 6*/
- const commando = require('discord.js-commando');
- const db = require('../../config/db');
- const skills = require('../../funcs/tradeskills');
- module.exports = class Farming extends commando.Command {
- constructor (client) {
- super(client, {
- name: 'gather',
- aliases: ['get'],
- group: 'actions',
- memberName: 'gather',
- hasPermissions: ['READ_MESSAGE_HISTORY'],
- description: 'gathering actions',
- guildOnly: true,
- args: [
- {
- key: 'what',
- prompt: 'What do you want to gather? List: Farming, herbology, hunting, lumber, mining, stone.',
- type: 'string',
- },
- {
- key: 'type',
- prompt: 'What to gather from selected tradeskill?',
- type: 'string',
- },
- {
- key: 'amount',
- prompt: 'How many actions before a report is sent. 10-1000',
- type: 'integer',
- },
- ],
- });
- }
- run(msg, { what, type, amount }) {
- // asign user
- var userData = msg.member.user;
- // Check for channel
- if (msg.channel.name != 'tradeskills-1' && msg.channel.name != 'tradeskills-2') {
- return msg.reply('Please use the tradeskill channels for this command.');
- }
- // Battle report check
- if (amount <= 9 || amount >= 1001) {
- return msg.reply('The action report amount must be 10-1000, please try again.');
- }
- // Check if registered
- var userSQL = 'SELECT * FROM users_meta WHERE userid = ?';
- db.query(userSQL, userData.id, (err, row) => {
- if (row[0] === undefined) {
- return msg.reply('You are not registered!');
- } else {
- // set game data for user - if already exists, update
- userData.game = row[0];
- // Set type to lowercase
- what = what.toLowerCase();
- type = type.toLowerCase();
- var expertise;
- var sendMsg;
- var stats = {
- exp: 0,
- actions: amount,
- yield: 0,
- };
- // Farming Block
- if (what === 'farming' || what === 'food') {
- sendMsg = 'You are now farming: ' + type;
- expertise = Math.floor((userData.game.farming_expgain +
- userData.game.farming_yield + userData.game.farming_double) / 2);
- switch (type) {
- case 'wheat':
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- break;
- case 'carrot':
- if (expertise <= 9) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 10 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- case 'tomato':
- if (expertise <= 24) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 25 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- case 'cucumber':
- if (expertise <= 39) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 40 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- case 'potato':
- if (expertise <= 59) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 60 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- default:
- return msg.reply('You did not produce the correct arguments.');
- }
- // Herb Block
- } else if (what === 'herbology' || what === 'herbs') {
- sendMsg = 'You are now gathering: ' + type;
- expertise = Math.floor((userData.game.herbology_expgain +
- userData.game.herbology_yield + userData.game.herbology_double) / 2);
- switch (type) {
- case 'basil':
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- break;
- case 'cilantro':
- if (expertise <= 9) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 10 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- case 'dill':
- if (expertise <= 24) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 25 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- case 'thyme':
- if (expertise <= 39) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 40 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- case 'garlic':
- if (expertise <= 59) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 60 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- default:
- return msg.reply('You did not produce the correct arguments.');
- }
- // start hunting block
- } else if (what === 'hunting' || what === 'hunt') {
- sendMsg = 'You are now hunting: ' + type;
- expertise = Math.floor((userData.game.hunting_expgain +
- userData.game.hunting_yield + userData.game.hunting_double) / 2);
- switch (type) {
- case 'rabbit':
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- break;
- case 'wolf':
- if (expertise <= 9) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 10 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- case 'deer':
- if (expertise <= 24) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 25 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- case 'bear':
- if (expertise <= 39) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 40 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- case 'dragon':
- if (expertise <= 59) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 60 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- default:
- return msg.reply('You did not produce the correct arguments.');
- }
- // start lumber block
- } else if (what === 'lumber' || what === 'wood') {
- sendMsg = 'You are now chopping: ' + type;
- expertise = Math.floor((userData.game.lumber_expgain +
- userData.game.lumber_yield + userData.game.lumber_double) / 2);
- switch (type) {
- case 'oak':
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- break;
- case 'birch':
- if (expertise <= 9) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 10 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- case 'cypruss':
- if (expertise <= 24) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 25 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- case 'pine':
- if (expertise <= 39) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 40 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- case 'spruce':
- if (expertise <= 59) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 60 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- default:
- return msg.reply('You did not produce the correct arguments.');
- }
- // start mining block
- } else if (what === 'mining' || what === 'mine') {
- sendMsg = 'You are now mining: ' + type;
- expertise = Math.floor((userData.game.mining_expgain +
- userData.game.mining_yield + userData.game.mining_double) / 2);
- switch (type) {
- case 'copper':
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- break;
- case 'iron':
- if (expertise <= 9) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 10 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- case 'silver':
- if (expertise <= 24) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 25 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- case 'malachite':
- if (expertise <= 39) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 40 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- case 'cobalt':
- if (expertise <= 59) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 60 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- default:
- return msg.reply('You did not produce the correct arguments.');
- }
- // start stone block
- } else if (what === 'stone') {
- sendMsg = 'You are now excavating: ' + type;
- expertise = Math.floor((userData.game.stone_expgain +
- userData.game.stone_yield + userData.game.stone_double) / 2);
- switch (type) {
- case 'basalt':
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- break;
- case 'granite':
- if (expertise <= 9) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 10 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- case 'quartz':
- if (expertise <= 24) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 25 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- case 'marble':
- if (expertise <= 39) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 40 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- case 'obsidian':
- if (expertise <= 59) {
- return msg.reply('You do not meet the expertise requirement. You have ' + expertise + ' but need 60 or more.');
- } else {
- msg.reply(sendMsg);
- autos(msg, what, type, amount, userData, stats);
- }
- break;
- default:
- return msg.reply('You did not produce the correct arguments.');
- }
- } else {
- return msg.reply('You did not produce the correct arguments.');
- }
- }
- function autos(msg, what, type, amount, userData, stats) {
- if (userData.interval === undefined || userData.interval === false) {
- userData.interval = setInterval(() => {
- skills.tradeSkill(msg, what, type, amount, userData, stats);
- userData.intervalTime = Date.now();
- }, 6000);
- skills.tradeSkill(msg, what, type, amount, userData, stats);
- } else {
- var timing = userData.intervalTime + 5900 - Date.now();
- if (timing < 0) {
- timing = 0;
- }
- // Waits for current to end, then updates it.
- setTimeout(() => {
- clearInterval(userData.interval);
- userData.interval = setInterval(() => {
- skills.tradeSkill(msg, what, type, amount, userData, stats);
- userData.intervalTime = Date.now();
- }, 6000);
- skills.tradeSkill(msg, what, type, amount, userData, stats);
- }, timing);
- }
- }
- });
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment