kingbootoshi hearth .cursorrules file for TypeScript (stars: 2)

This codebase is a typescript discord.js modular discord bot capable of interacting with the community in discord.

This bot is also capable of running different command functionalities based on modules and commands added in the src/commands folder.

Command functionality should be created as a module in the src/modules folder. Adding the command to the discord bot is done in the src/commands folder.

Guide: Adding New Commands
------------------------

To add a new command to the bot, follow these steps:

1. Create a Module (if needed):
   - Create a new folder in src/modules for your command's functionality
   - Implement the core logic and utilities in this module
   - Export the necessary functions that will be used by the command

2. Create Command File:
   - Add a new TypeScript file in src/commands (e.g., myCommand.ts)
   - File must export:
     ```typescript
     // Command definition
     export const data = new SlashCommandBuilder()
       .setName('commandname')
       .setDescription('what the command does')
       .addXXXOption(...); // Add any needed options

     // Command execution logic
     export async function execute(interaction: ChatInputCommandInteraction) {
       // Implementation
     }

     // Button handler (if command uses buttons)
     export async function handleButtonInteraction(
       interaction: ButtonInteraction
     ): Promise<void> {
       // Button handling logic
     }
     ```

3. Command Structure:
   - Use proper error handling and logging
   - Defer replies for operations that might take time
   - Use embeds and buttons for rich interactions
   - Follow the existing command patterns for consistency

4. Button Interactions:
   - If your command includes button interactions, update the CommandHandler.ts file to handle the button events.

The command will be automatically loaded when added to the commands folder. If your command includes button interactions, update the CommandHandler.ts file to handle the button events.

Commands are automatically loaded in when they are added to the commands folder, however button functionality has to be differentiated in the CommandHandler.ts file.

I am using the PINO logger for logging. Please log everything with depth

- Use info to log the flow of the program
- Use debug to log more detailed and full outputs
- Use error to log errors

Guide: Creating New Tools for the Chatbot
----------------------------------------

To add a new tool that the chatbot can use, follow these steps:

1. Define the Tool in config/chatbotTools.yaml:
   - Add a new tool definition under the 'tools' array
   - Specify type: "function"
   - Define the function name, description, and parameters
   - Mark required parameters and set additionalProperties to false
   Example:
   ```yaml
   - type: "function"
     function:
       name: "tool_name"
       description: "What the tool does"
       parameters:
         type: "object"
         properties:
           param1:
             type: "string"
             description: "Parameter description"
         required: ["param1"]
         additionalProperties: false
   ```

2. Create Tool Handler in src/modules/chatbotModule/tools/toolHandler.ts:
   - Define the argument interface for your tool
   - Create a handler function that takes (args, client)
   - Implement the tool's functionality
   - Add proper logging using pino
   - Add the tool to the executeToolCall switch statement
   Example:
   ```typescript
   interface ToolArgs {
     param1: string;
   }

   async function handleTool(args: ToolArgs, client: Client): Promise<string> {
     logger.info({ args }, '[tool_name] Tool invoked');
     try {
       // Tool implementation
       return 'Success message';
     } catch (error) {
       logger.error({ error }, 'Error in tool');
       throw error;
     }
   }
   ```

3. Testing:
   - The tool will be automatically available to the chatbot
   - The chatbot will use the tool when appropriate based on the tool's description
   - Tool execution results are fed back to the chatbot for further processing

Note: Tools should be atomic and focused on a single responsibility. Complex functionality should be broken down into multiple tools that can be chained together using the run_again tool.
javascript
plpgsql
typescript

First Time Repository

Your AI discord community manager

TypeScript

Languages:

JavaScript: 9.3KB
PLpgSQL: 6.2KB
TypeScript: 236.9KB
Created: 7/5/2024
Updated: 1/22/2025

All Repositories (1)

Your AI discord community manager