moeru-ai/airi · error · ActionError

ITEM_NOT_FOUND

ITEM_NOT_FOUND

Error message

You do not have any ${name} to eat

What it means

Thrown by consume() when no inventory item matches: if itemName is given, an exact item.name === itemName match; if itemName is empty/default, any item whose name includes 'food'. It is an ActionError with code ITEM_NOT_FOUND and context { item: name }. The function logs to the player before throwing.

Source

Thrown at integrations/minecraft/src/skills/inventory.ts:142

      }
    }
  })
  return true
}

/**
 * Consume (eat/drink) an item from the bot's inventory.
 * @param mineflayer The mineflayer instance.
 * @param itemName The name of the item to consume.
 * @throws {ActionError} When the item is not found in inventory.
 */
export async function consume(mineflayer: Mineflayer, itemName = ''): Promise<void> {
  const item = mineflayer.bot.inventory.items().find(item => itemName ? item.name === itemName : item.name.includes('food'))

  if (!item) {
    const name = itemName || 'food'
    log(mineflayer, `You do not have any ${name} to eat.`)
    throw new ActionError('ITEM_NOT_FOUND', `You do not have any ${name} to eat`, { item: name })
  }

  await mineflayer.bot.equip(item, 'hand')
  await mineflayer.bot.consume()
  log(mineflayer, `Consumed ${item.name}.`)
}

export async function giveToPlayer(
  mineflayer: Mineflayer,
  itemType: string,
  username: string,
  num = 1,
): Promise<void> {
  const player = mineflayer.bot.players[username]?.entity
  if (!player) {
    log(mineflayer, `Could not find ${username}.`)
    throw new ActionError('TARGET_NOT_FOUND', `Could not find ${username}`, { target: username })
  }

View on GitHub (pinned to 27111382b4)

Solutions

  1. Pass the exact item id of a food item present in inventory (e.g. 'cooked_beef'), verified via inventory.items().
  2. Gather food first (hunt/cook/farm) before calling consume.
  3. Do not rely on the no-argument form for vanilla food — pass an explicit name.

Example fix

// before
await consume(mineflayer) // relies on name.includes('food')

// after
const food = mineflayer.bot.inventory.items().find(i => i.name.includes('beef') || i.name === 'bread')
if (!food) throw new Error('No food available')
await consume(mineflayer, food.name)
Defensive patterns

Strategy: validation

Validate before calling

const items = mineflayer.bot.inventory.items()
const target = itemName ? items.find(i => i.name === itemName) : items.find(i => i.name.includes('food'))
if (!target) throw new Error(`No ${itemName || 'food'} in inventory`)
await consume(mineflayer, itemName)

Type guard

import { ActionError } from '../utils/errors'
function isNoFoodError(e: unknown): boolean {
  return e instanceof ActionError && e.code === 'ITEM_NOT_FOUND' && /to eat/.test(e.message)
}

Try / catch

try {
  await consume(mineflayer, itemName)
} catch (e) {
  if (e instanceof ActionError && e.code === 'ITEM_NOT_FOUND') {
    // gather or cook food, then retry with an explicit name
  } else throw e
}

Prevention

When it happens

Trigger: Calling consume(mineflayer, 'bread') with no bread in inventory; calling consume(mineflayer) (no name) when no inventory item name contains the substring 'food'; passing a non-food item name that the bot does not carry.

Common situations: Bot's inventory was emptied by a prior discard/give; user asked to eat an item the bot never collected; minecraft item id for food does not literally contain 'food' (e.g. 'bread', 'cooked_beef') so the no-argument fallback never matches vanilla food.

Related errors


AI-assisted analysis of moeru-ai/airi@27111382b4 (2026-08-12). Data as JSON: /api/errors/f02709265c4f234c. Report an issue: GitHub.