kolbytn / mindcraft

MIT License
2.21k stars 267 forks source link

!help command to see docs #294

Open MaxRobinsonTheGreat opened 2 weeks ago

hackdefendr commented 4 days ago

OK here is my first attempt. This works for the functionality, but the formatting isn't pretty yet.

    {
        name: '!help',
        description: 'Lists all available commands and their descriptions.',
        perform: async function (agent) {
            const commandList = actionsList.map(action => {
                return `${action.name}: ${action.description}`;
            }).join('\n');
            return `Here are the available commands:\n ${commandList}`;
        }
    },

I just added this at the end of src/agent/commands/actions.js

hackdefendr commented 3 days ago

Final draft with some formatting to prettify the output.

{
    name: '!help',
    description: 'Lists all available commands and their descriptions.',
    perform: async function (agent) {
        const commandList = actionsList.map(action => {
            return `${action.name.padEnd(15)} - ${action.description}`; // Ensure consistent spacing
        }).join('\n');

        console.log(commandList);
        return `Available Commands:\n${commandList}`;
    }
}

Which will output this to the console:

Available Commands:
!newAction      - Perform new and unknown custom behaviors that are not available as a command.
!stop           - Force stop all actions and commands that are currently executing.
!stfu           - Stop all chatting and self-prompts but continue current action execution.
!restart        - Restart the agent process safely.
!clearChat      - Clear the current chat history.
!goToPlayer     - Navigates the bot to the specified player.
!followPlayer   - Follows the specified player from a certain distance.
!goToBlock      - Navigates the bot to the nearest specified block type.
!moveAway       - Moves the bot away from the current position by the specified distance.
!rememberHere   - Saves the current location with a given name.
!goToPlace      - Navigates the bot to a pre-saved location.
!givePlayer     - Gives the specified item to the given player.
!discard        - Discards the given items from the bot’s inventory.
!help           - Lists all available commands and their descriptions.

Do you want me to go through the Pull Request process?