discord_get_message_history
Retrieve message history from a Discord channel with filters like limit, before, after, or around specific message IDs for precise data access and management.
Instructions
Get message history from a Discord channel with optional filtering
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| after | No | Get messages after this message ID | |
| around | No | Get messages around this message ID | |
| before | No | Get messages before this message ID | |
| channelId | Yes | The Discord channel ID | |
| limit | No | Number of messages to retrieve (1-100, default: 50) |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"after": {
"description": "Get messages after this message ID",
"type": "string"
},
"around": {
"description": "Get messages around this message ID",
"type": "string"
},
"before": {
"description": "Get messages before this message ID",
"type": "string"
},
"channelId": {
"description": "The Discord channel ID",
"type": "string"
},
"limit": {
"description": "Number of messages to retrieve (1-100, default: 50)",
"maximum": 100,
"minimum": 1,
"type": "number"
}
},
"required": [
"channelId"
],
"type": "object"
}
Implementation Reference
- src/core/AutomationManager.ts:526-529 (handler)Handler function that implements the core logic for the 'discord_get_message_history' tool. It parses input parameters using the schema and delegates execution to DiscordService.getMessageHistory.async getMessageHistory(channelId?: string, limit?: number, before?: string, after?: string): Promise<string> { const parsed = schemas.GetMessageHistorySchema.parse({ channelId, limit, before, after }); return await this.discordService.getMessageHistory(parsed.channelId, parsed.limit, parsed.before, parsed.after); }
- src/types.ts:328-333 (schema)Zod schema for input validation of the 'discord_get_message_history' tool, defining parameters like channelId, limit, before, and after.export const GetMessageHistorySchema = z.object({ channelId: z.string().describe("Channel ID"), limit: z.number().optional().describe("Number of messages to fetch"), before: z.string().optional().describe("Message ID to fetch before"), after: z.string().optional().describe("Message ID to fetch after") });
- src/core/DiscordController.ts:69-80 (registration)Dynamic registration and dispatch mechanism that converts snake_case tool names (e.g., 'get_message_history') to camelCase method names and invokes the corresponding handler on AutomationManager.private async callAutomationMethod(action: string, params: any): Promise<string> { // Convert action name to method name (snake_case to camelCase) const methodName = action.replace(/_([a-z])/g, (g) => g[1].toUpperCase()); // Check if method exists if (typeof (this.automationManager as any)[methodName] === 'function') { // Call the method with params return await (this.automationManager as any)[methodName](...Object.values(params)); } throw new Error(`Method '${methodName}' not found in AutomationManager`); }