Skip to content

Commit

Permalink
Implement gardening system
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek committed Apr 2, 2021
1 parent 6d1dc64 commit ff06616
Show file tree
Hide file tree
Showing 6 changed files with 395 additions and 66 deletions.
63 changes: 32 additions & 31 deletions commands/daily.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
const ms = require('ms')
exports.run = async (client, message, args) => {
try {
const prefix = message.guild === null ? ';;' : client.getSettings(message.guild.id).prefix
try {
const prefix = message.guild === null ? ';;' : client.getSettings(message.guild.id).prefix

client.cooldown.ensure(`${message.author.id}`, {
member: message.author.id,
dailbonusy: 0,
rep: 0
})
client.cooldown.ensure(`${message.author.id}`, {
member: message.author.id,
dailybonus: 0,
rep: 0,
plants: 0
})

const cooldown = client.cooldown.get(message.author.id, 'dailybonus')
const cooldown = client.cooldown.get(message.author.id, 'dailybonus')

var today = new Date();
var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
var today = new Date();
var date = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();

if (cooldown === date) return message.channel.send(`You have already collected your daily bonus today!`)
if (cooldown === date) return message.channel.send(`You have already collected your daily bonus today!`)

client.cooldown.set(`${message.author.id}`, date, 'dailybonus') // Activate 24 hour cooldown
client.cooldown.set(`${message.author.id}`, date, 'dailybonus') // Activate 24 hour cooldown

client.money.ensure(`${message.author.id}`, {
member: message.author.id,
money: 0
})
client.money.ensure(`${message.author.id}`, {
member: message.author.id,
money: 0
})

const money = client.money.get(message.author.id, 'money')
client.money.set(`${message.author.id}`, money + 100, 'money')
message.channel.send(`You claimed your daily bonus of \`$${100}\`.`)
} catch (err) {
message.channel.send(client.errors.genericError + err.stack).catch();
}
const money = client.money.get(message.author.id, 'money')
client.money.set(`${message.author.id}`, money + 100, 'money')
message.channel.send(`You claimed your daily bonus of \`$${100}\`.`)
} catch (err) {
message.channel.send(client.errors.genericError + err.stack).catch();
}
}

exports.conf = {
enabled: true,
aliases: ['claim', 'bonus', 'dailybonus'],
guildOnly: false,
permLevel: 'User'
enabled: true,
aliases: ['claim', 'bonus', 'dailybonus'],
guildOnly: false,
permLevel: 'User'
}

exports.help = {
name: 'daily',
category: 'Economy',
description: 'Claim your daily bonus every 24 hours.',
usage: 'daily'
}
name: 'daily',
category: 'Economy',
description: 'Claim your daily bonus every 24 hours.',
usage: 'daily'
}
53 changes: 53 additions & 0 deletions commands/garden.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const Discord = require('discord.js')
const colors = require('../lib/colors.json')

exports.run = async (client, message, args) => {
try {
if (message.author.bot === true) return

client.garden.ensure(message.author.id, {
member: message.author.id,
plant1: null,
plant2: null,
plant3: null,
plant1Stage: "0",
plant2Stage: "0",
plant3Stage: "0",
})

const p1 = client.garden.get(`${message.author.id}`, 'plant1')
const p2 = client.garden.get(`${message.author.id}`, 'plant2')
const p3 = client.garden.get(`${message.author.id}`, 'plant3')
var s1 = client.garden.get(`${message.author.id}`, 'plant1Stage')
var s2 = client.garden.get(`${message.author.id}`, 'plant2Stage')
var s3 = client.garden.get(`${message.author.id}`, 'plant3Stage')

var f1 = s1.replace('1', '').replace('2', ':seedling: ').replace('3', ':seedling: ').replace('4', `:${p1}: `)
var f2 = s2.replace('1', '').replace('2', ':seedling: ').replace('3', ':seedling: ').replace('4', `:${p2}: `)
var f3 = s3.replace('1', '').replace('2', ':seedling: ').replace('3', ':seedling: ').replace('4', `:${p3}: `)

const empty = client.emojis.cache.get("827352923339227186");
if (f1 === "0") f1 = empty
if (f2 === "0") f2 = empty
if (f3 === "0") f3 = empty

const grass = client.emojis.cache.get("827308950428712960");
message.channel.send(`${f1}${f2}${f3}\n${grass}${grass}${grass}`)
} catch (err) {
message.channel.send(client.errors.genericError + err.stack).catch();
}
}

exports.conf = {
enabled: true,
aliases: [],
guildOnly: true,
permLevel: 'User'
}

exports.help = {
name: 'garden',
category: 'Fun',
description: 'Shows your garden.',
usage: 'garden'
}
89 changes: 89 additions & 0 deletions commands/harvest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
const Discord = require('discord.js')
const colors = require('../lib/colors.json')

exports.run = async (client, message, args) => {
try {
if (message.author.bot === true) return

client.garden.ensure(message.author.id, {
member: message.author.id,
plant1: null,
plant2: null,
plant3: null,
plant1Stage: "0",
plant2Stage: "0",
plant3Stage: "0",
})

if (args[0] === '1' || args[0] === '2' || args[0] === '3') {
let slot = ''
let stage
if (args[0] === '1') {
slot = 'plant1'
stage = 'plant1Stage'
}
if (args[0] === '2') {
slot = 'plant2'
stage = 'plant2Stage'
}
if (args[0] === '3') {
slot = 'plant3'
stage = 'plant3Stage'
}

var getPlant = client.garden.get(`${message.author.id}`, slot)
var getStage = client.garden.get(`${message.author.id}`, stage)

if (getStage !== "4") return message.channel.send("This plant is not ripe enough to be harvested yet.")

client.garden.set(`${message.author.id}`, null, slot)
client.garden.set(`${message.author.id}`, "0", stage)

var rarity
if (getPlant === "hibiscus" || getPlant === "ear_of_rice" || getPlant === "blossom" || getPlant === "rose") rarity = "common"
if (getPlant === "tanabata_tree" || getPlant === "bamboo" || getPlant === "sunflower" || getPlant === "moneybag") rarity = "uncommon"
if (getPlant === "deciduous_tree" || getPlant === "evergreen_tree" || getPlant === "chest") rarity = "rare"
if (getPlant === "palm_tree" || getPlant === "cactus" || getPlant === "chest") rarity = "very rare"
if (getPlant === "skull" || getPlant === "bone" || getPlant === "t_rex" || getPlant === "sauropod") rarity = "legendary"

var worth
if (rarity === "common") worth = 100
if (rarity === "uncommon") worth = 200
if (rarity === "rare") worth = 300
if (rarity === "very rare") worth = 500
if (rarity === "legendary") worth = 1000

client.money.ensure(`${message.author.id}`, {
member: message.author.id,
money: 0
})

const money = client.money.get(message.author.id, 'money')
client.money.set(`${message.author.id}`, money + worth, 'money')

const embed = new Discord.MessageEmbed()
.setAuthor('🌼 Garden')
.setColor(colors.green)
.setDescription(`You harvested a **${rarity}** :${getPlant}: for **${worth}**!`)
return message.channel.send(embed)
} else {
message.channel.send('You need to specify which slot you want to harvest (1-3)')
}
} catch (err) {
message.channel.send(client.errors.genericError + err.stack).catch();
}
}

exports.conf = {
enabled: true,
aliases: [],
guildOnly: true,
permLevel: 'User'
}

exports.help = {
name: 'garden',
category: 'Fun',
description: 'Shows your garden.',
usage: 'garden'
}
108 changes: 108 additions & 0 deletions commands/plant.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
const Discord = require('discord.js')
const colors = require('../lib/colors.json')
const ms = require('ms')
exports.run = async (client, message, args) => {
try {
const prefix = message.guild === null ? ';;' : client.getSettings(message.guild.id).prefix

client.inventory.ensure(message.author.id, {
member: message.author.id,
rings: 0,
petfood: 0,
seeds: 0,
})

const seeds = client.inventory.get(message.author.id, 'seeds')

if (seeds === 0) return message.channel.send('You do not have any seeds. Buy some in the shop.')

client.garden.ensure(message.author.id, {
member: message.author.id,
plant1: null,
plant2: null,
plant3: null,
plant1Stage: "0",
plant2Stage: "0",
plant3Stage: "0",
})

const p1 = client.garden.get(`${message.author.id}`, 'plant1')
const p2 = client.garden.get(`${message.author.id}`, 'plant2')
const p3 = client.garden.get(`${message.author.id}`, 'plant3')

if (!args[0]) return message.channel.send('You need to specify which slot you want to plant the seed in (1-3)')

if (args[0] === '1' || args[0] === '2' || args[0] === '3') {
let slot = ''
let stage
if (args[0] === '1') {
slot = 'plant1'
stage = 'plant1Stage'
}
if (args[0] === '2') {
slot = 'plant2'
stage = 'plant2Stage'
}
if (args[0] === '3') {
slot = 'plant3'
stage = 'plant3Stage'
}
if (args[0] > 3) return message.channel.send('You can only have 3 plants in your garden at a time.')

var d = Math.random()
let plant;
if (d < 0.5) {
const choices = ["hibiscus", "ear_of_rice", "blossom", "rose"];

const random = Math.floor(Math.random() * choices.length);
plant = choices[random];
} else if (d < 0.75) {
const choices = ["tanabata_tree", "bamboo", "sunflower", "moneybag"];

const random = Math.floor(Math.random() * choices.length);
plant = choices[random];
} else if (d < 0.9) {
const choices = ["deciduous_tree", "evergreen_tree", "chest"];

const random = Math.floor(Math.random() * choices.length);
plant = choices[random];
} else if (d < 0.95) {
const choices = ["palm_tree", "cactus"];

const random = Math.floor(Math.random() * choices.length);
plant = choices[random];
} else if (d < 0.99) {
const choices = ["bone", "skull", "t_rex", "sauropod"];

const random = Math.floor(Math.random() * choices.length);
plant = choices[random];
}

client.garden.set(`${message.author.id}`, plant, slot)
client.garden.set(`${message.author.id}`, "1", stage)
const embed = new Discord.MessageEmbed()
.setAuthor('🌼 Garden')
.setColor(colors.green)
.setDescription(`You planted a seed in slot \`${args[0]}\`. Be sure to water it every 24 hours with \`` + prefix + 'water`.')
return message.channel.send(embed)
} else {
message.channel.send('You need to specify which slot you want to plant the seed in (1-3)')
}
} catch (err) {
message.channel.send(client.errors.genericError + err.stack).catch();
}
}

exports.conf = {
enabled: true,
aliases: [],
guildOnly: false,
permLevel: 'User'
}

exports.help = {
name: 'plant',
category: 'Fun',
description: 'Plant seeds in your ;;garden.',
usage: 'plant <slot>'
}
Loading

0 comments on commit ff06616

Please sign in to comment.