Skip to content

Commit 04568a1

Browse files
atiwebCopilot
andauthored
Update src/agent/modes.js
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 3b2a3f3 commit 04568a1

1 file changed

Lines changed: 9 additions & 16 deletions

File tree

src/agent/modes.js

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -258,24 +258,17 @@ const modes_list = [
258258
const beds = bot.findBlocks({
259259
matching: (block) => block.name.includes('bed'),
260260
maxDistance: 32,
261-
count: 1
262-
});
263-
if (beds.length > 0) {
264-
execute(this, agent, async () => {
261+
// Let skills.goToBed handle finding a suitable bed
262+
execute(this, agent, async () => {
263+
try {
264+
await skills.goToBed(bot);
265265
say(agent, 'It\'s getting dark, I should sleep.');
266-
try {
267-
await skills.goToBed(bot);
268-
} catch (e) {
269-
if (e && e.message && e.message.includes('occupied')) {
270-
say(agent, 'The bed is occupied.');
271-
} else {
272-
const errorMessage = e && e.message ? e.message : 'unknown reason';
273-
console.log('[AUTO_SLEEP] Error:', errorMessage);
274-
say(agent, `I couldn't sleep (${errorMessage}).`);
275-
}
266+
} catch (e) {
267+
if (e && e.message && e.message.includes('occupied')) {
268+
say(agent, 'The bed is occupied.');
276269
}
277-
});
278-
}
270+
}
271+
});
279272
}
280273
},
281274
{

0 commit comments

Comments
 (0)