I always get undefined when I want to use x.st, and I'm asking this because I want to add a sticker and if I add a sticker maybe it will look more interesting
code for buy
const { MessageEmbed } = require("discord.js");
exports.execute = async (client, message, args) => {
let userBalance = client.eco.fetchMoney(message.author.id);
if (userBalance.amount < 1) return message.channel.send("Bruhh");
let item = args[0];
if (!item) return message.channel.send("enter animal name after zoobuy. example: zoobuy whale");
let hasItem = client.anbuy[item];
if (!hasItem || hasItem == undefined) return message.reply(`Animal with name ${item} not found`);
let isBalanceEnough = (userBalance.amount >= hasItem.cost); if (!isBalanceEnough) return message.reply("you need "+hasItem.cost+" to buy this animal.");
let buy = client.eco.removeMoney(message.author.id, hasItem.cost);
let itemStruct = {
name: item.toLowerCase(),
sti: hasItem.st
};
client.db.push(`animal_${message.author.id}`, itemStruct);
return message.channel.send(`Success delivery **${item}** to your zoo. you purchased **${item}** for ${hasItem.cost} .`);
};
exports.help = {
name: "zoobuy",
aliases: [],
usage: `zoobuy <item>`
};
code for zoo
const { MessageEmbed } = require("discord.js")
exports.execute = async (client, message, args) => {
const embed = new MessageEmbed()
.setAuthor(` ${message.author.tag} Zoo `, message.guild.iconURL)
.setColor("#8F00FF")
.setThumbnail()
.setTimestamp();
const x = client.db.get(`animal_${message.author.id}`);
if(!x) { return message.channel.send(`You don't have animals in your zoo`); } const arrayToObject = x.reduce((itemsobj, x) => {
itemsobj[x.name] = (itemsobj[x.name] || 0) + 1;
return itemsobj;
}, {});
const result = Object.keys(arrayToObject).map(k => embed.addField(`Animal: ${k} ${x.st}`,`Total: **${arrayToObject[k]}**`, false));
return message.channel.send(embed);
}
exports.help = {
name: "zoo",
aliases: [],
usage: `zoo`
}
i need add sticker because if i add sticker it looks nice