const { weaponshop, slots, rarecars, simplecars, houses, cars, phones, weapons, equipment, UserModel, WorldModel, JobModel, PropertyModel, BusinessModel, ReportModel, BlockModel, PromocodeModel, mainChat, adminList, expToUp, topSym } = require('/dev/Telegram/CampFireGameBot/config') const { spaces, spacesWithMarkdown, escape, generatePromo, generateVoucher, getCurrentTime, getSlot, giveExp, matPriceUpdate, rand, random, setCooldown, weaponShopUpdate, stats } = require('/dev/Telegram/CampFireGameBot/utils') module.exports = async (ctx) => { ctx.args = ctx.update.message.text.split(' ') let user = await UserModel.findByPk(ctx.from.id) let property = await PropertyModel.findByPk(ctx.from.id); let world = await WorldModel.findByPk(1) if (!ctx.args[1]) return ctx.reply(`Не указан аргумент.`) if (ctx.args[1] == "house") { if (!property.house.name) return await ctx.reply(`У вас нет дома.`) let name = property.house.name user.money += Math.round(property.house.price/2) world.balance -= Math.round(property.house.price/2) property.house = 0 await user.save() await world.save() await property.save() return await ctx.reply(`Вы продали ${name}`) } if (ctx.args[1] == "car") { if (!property.car1.name) return await ctx.reply(`У вас нет автомобиля.`) let name = property.car1.name user.money += Math.round(property.car1.price/1.2) world.balance -= Math.round(property.car1.price/1.2) property.car1 = 0 await user.save() await world.save() await property.save() return await ctx.reply(`Вы продали ${name}`) } if (ctx.args[1] == "phone") { if (!property.mobile.name) return await ctx.reply(`У вас нет телефона.`) let name = property.mobile.name user.money += Math.round(property.mobile.price/2) world.balance -= Math.round(property.mobile.price/2) property.mobile = 0 await user.save() await world.save() await property.save() return await ctx.reply(`Вы продали ${name}`) } if (ctx.args[1] == "equipment") { if (!property.equipment.name) return await ctx.reply(`У вас нет экипировки.`) let name = property.equipment.name user.money += Math.round(property.equipment.price/2) world.balance -= Math.round(property.equipment.price/2) property.equipment = 0 await user.save() await world.save() await property.save() return await ctx.reply(`Вы продали ${name}`) } if (ctx.args[1] == "weapon") { if (!property.weapon.name) return await ctx.reply(`У вас нет оружия.`) let name = property.weapon.name user.money += Math.round(property.weapon.price/2) world.balance -= Math.round(property.weapon.price/2) property.weapon = 0 await user.save() await world.save() await property.save() return await ctx.reply(`Вы продали ${name}`) } }