const { UserModel, WorldModel, BusinessModel } = global.config module.exports = async (ctx) => { let user = await UserModel.findByPk(ctx.from.id) if (user.business.id != 0){ let business = await BusinessModel.findOne({ where: { owner: ctx.from.id.toString() } }) } let business = null let world = await WorldModel.findByPk(1) ctx.args = ctx.update.message.text.split(' ') if (business != null) return await ctx.reply(`У вас уже есть организация.`) if (!ctx.args[1]) return ctx.reply(`/business [Название организации]`) if (user.money < 100000) return await ctx.reply(`Регистрация организации стоит ₽100.000`) if (user.level < 5) return await ctx.reply(`Регистрация организации доступна с 5 уровня.`) user.money -= 100000 world.balance += 100000 let text = `` for (i = 1; i < ctx.args.length; i++) { text += `${ctx.args[i]} ` } if (business === null) { BusinessModel.create({ name: text, owner: user.telegram_id, balance: 50000, users: [user.telegram_id] }) user.business = { id: user.telegram_id, checks: 0, percent: 100 } } else {} user.save() world.save() return await ctx.reply(`Организация "${text}" успешно создана!\n Регистрация организации в реестре: ₽50.000 \n Капитал: ₽50.000`) }