Skip to main content
Glama
goToSomeone.ts1.78 kB
import { Bot } from 'mineflayer'; import { ISkillServiceParams, ISkillParams } from '../../types/skillType.js'; import { validateSkillParams } from '../index.js'; import { goToPerson } from '../library/goToPerson.js'; /** * Goes to someone to get near them or follow them. * * @param {Bot} bot - The Mineflayer bot instance. Assume the bot is already spawned in the world. * @param {object} params * @param {string} params.userName - The name of the person to go to or follow. * @param {number} params.distance - The desired distance to get within the person. Default is 3 blocks. * @param {boolean} params.keepFollowing - Whether to keep following the person after reaching them. Default is false. * @param {object} serviceParams - additional parameters for the skill function. * * @return {Promise<boolean>} - Returns true if the bot successfully went to the person, false otherwise. */ export const goToSomeone = async ( bot: Bot, params: ISkillParams, serviceParams: ISkillServiceParams, ): Promise<boolean> => { const skillName = 'goToSomeone'; const requiredParams = ['userName']; const isParamsValid = validateSkillParams( params, requiredParams, skillName, ); if (!isParamsValid) { serviceParams.cancelExecution?.(); bot.emit( 'alteraBotEndObservation', `Mistake: You didn't provide all of the required parameters ${requiredParams.join(', ')} for the ${skillName} skill.`, ); return false; } const defaultParams = { keepFollowing: true, distance: 3, }; return goToPerson(bot, { name: params.userName, distance: params.distance ?? defaultParams.distance, keepFollowing: params.keepFollowing ?? defaultParams.keepFollowing, signal: serviceParams.signal, }); };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/leo4life2/minecraft-mcp-http'

If you have feedback or need assistance with the MCP directory API, please join our Discord server