(slot, pages, author, title, signing)
| 35 | } |
| 36 | |
| 37 | async function write (slot, pages, author, title, signing) { |
| 38 | assert.ok(slot >= 0 && slot <= 44, 'slot out of inventory range') |
| 39 | const book = bot.inventory.slots[slot] |
| 40 | assert.ok(book && book.type === bot.registry.itemsByName.writable_book.id, `no book found in slot ${slot}`) |
| 41 | const quickBarSlot = bot.quickBarSlot |
| 42 | const moveToQuickBar = slot < 36 |
| 43 | |
| 44 | if (moveToQuickBar) { |
| 45 | await bot.moveSlotItem(slot, 36) |
| 46 | } |
| 47 | |
| 48 | bot.setQuickBarSlot(moveToQuickBar ? 0 : slot - 36) |
| 49 | |
| 50 | const modifiedBook = await modifyBook(moveToQuickBar ? 36 : slot, pages, author, title, signing) |
| 51 | editBook(modifiedBook, pages, title, moveToQuickBar ? 0 : slot - 36, signing) |
| 52 | await once(bot.inventory, `updateSlot:${moveToQuickBar ? 36 : slot}`) |
| 53 | |
| 54 | bot.setQuickBarSlot(quickBarSlot) |
| 55 | |
| 56 | if (moveToQuickBar) { |
| 57 | await bot.moveSlotItem(36, slot) |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | function modifyBook (slot, pages, author, title, signing) { |
| 62 | const book = Object.assign({}, bot.inventory.slots[slot]) |
no test coverage detected
searching dependent graphs…