From e77e43850ea376e6cc50c1facf429d6b1169a518 Mon Sep 17 00:00:00 2001 From: Hri7566 Date: Tue, 5 Mar 2024 17:36:46 -0500 Subject: [PATCH] Fix eating things --- src/api/commands/groups/inventory/eat.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/api/commands/groups/inventory/eat.ts b/src/api/commands/groups/inventory/eat.ts index 0fc2cea..f5d5da2 100644 --- a/src/api/commands/groups/inventory/eat.ts +++ b/src/api/commands/groups/inventory/eat.ts @@ -49,10 +49,12 @@ export const eat = new Command( if (foundObject.objtype == "fish") thingy = "fish"; const bhv = itemBehaviorMap[thingy]; + let res; + if (bhv) { if (!bhv["eat"]) return `You can't eat the ${foundObject.name}.`; - const res = await runBehavior(thingy, "eat", foundObject, props); + res = await runBehavior(thingy, "eat", foundObject, props); shouldRemove = res.shouldRemove; } else { shouldRemove = true; @@ -105,14 +107,16 @@ export const eat = new Command( } if (foundObject.id == "sand") { - if (res.and) { - return `Our friend ${part.name} ate of his/her ${foundObject.name} ${res.and}`; + if (res) { + if (res.and) + return `Our friend ${part.name} ate of his/her ${foundObject.name} ${res.and}`; } else { return `Our friend ${part.name} ate of his/her ${foundObject.name}.`; } } else { - if (res.and) { - return `Our friend ${part.name} ate his/her ${foundObject.name} ${res.and}`; + if (res) { + if (res.and) + return `Our friend ${part.name} ate his/her ${foundObject.name} ${res.and}`; } else { return `Our friend ${part.name} ate his/her ${foundObject.name}.`; }