import { EventEmitter } from 'events'; import { Agent } from '../core/agent'; import { AgentSwarm } from '../core/agent-swarm'; import { Message } from 'discord.js'; /** * Configuration for the Discord connector */ export interface DiscordConnectorConfig { token: string; prefix?: string; allowedChannels?: string[]; allowedUsers?: string[]; autoReply?: boolean; monitorKeywords?: string[]; pollInterval?: number; } /** * Internal Discord message interface to abstract away the library-specific implementation */ export interface DiscordMessage { id: string; content: string; author: { id: string; username: string; bot: boolean; }; channelId: string; guildId?: string; createdAt: Date; reference?: { messageId: string; channelId: string; guildId?: string; }; originalMessage: Message; } /** * Discord connector to integrate agents with Discord * Uses discord.js library to connect to Discord */ export declare class DiscordConnector extends EventEmitter { config: DiscordConnectorConfig; private agent?; private swarm?; private logger; private connected; private client; private monitorInterval; private messageCache; /** * Creates a new Discord connector * * @param config - Configuration for the connector */ constructor(config: DiscordConnectorConfig); /** * Connects an agent to Discord * * @param agent - The agent to connect * @returns Promise resolving when connected */ connect(agent: Agent | AgentSwarm): Promise; /** * Disconnects from Discord * * @returns Promise resolving when disconnected */ disconnect(): Promise; /** * Sets up event listeners for Discord events */ private setupEventListeners; /** * Handles commands with the configured prefix * * @param message - The Discord message containing the command */ private handleCommand; /** * Handles auto-reply to a message * * @param message - The message to reply to */ private handleAutoReply; /** * Sets up monitoring for Discord messages */ private setupMonitoring; /** * Checks for messages containing monitored keywords */ private checkForKeywordMentions; /** * Sends a message to a Discord channel * * @param channelId - ID of the channel to send the message to * @param content - Content of the message * @param options - Additional options for the message * @returns Promise resolving to the sent message ID */ sendMessage(channelId: string, content: string, options?: { files?: Array<{ name: string; data: Buffer | string; }>; embeds?: any[]; }): Promise; /** * Sends a reply to a message * * @param messageId - ID of the message to reply to * @param channelId - ID of the channel containing the message * @param content - Content of the reply * @param options - Additional options for the message * @returns Promise resolving to the sent message ID */ replyToMessage(messageId: string, channelId: string, content: string, options?: { files?: Array<{ name: string; data: Buffer | string; }>; embeds?: any[]; }): Promise; /** * Gets a specific message by ID * * @param messageId - ID of the message to get * @param channelId - ID of the channel containing the message * @returns Promise resolving to the message */ getMessage(messageId: string, channelId: string): Promise; /** * Gets recent messages from a channel * * @param channelId - ID of the channel to get messages from * @param limit - Maximum number of messages to get (default: 10) * @returns Promise resolving to an array of messages */ getChannelMessages(channelId: string, limit?: number): Promise; /** * Adds a reaction to a message * * @param messageId - ID of the message to react to * @param channelId - ID of the channel containing the message * @param emoji - Emoji to add as reaction * @returns Promise resolving when completed */ addReaction(messageId: string, channelId: string, emoji: string): Promise; /** * Gets all channels in a guild * * @param guildId - ID of the guild to get channels from * @returns Promise resolving to an array of channel objects */ getGuildChannels(guildId: string): Promise>; /** * Gets the guilds (servers) the bot is a member of * * @returns Promise resolving to an array of guild objects */ getGuilds(): Promise>; /** * Edits a message sent by the bot * * @param messageId - ID of the message to edit * @param channelId - ID of the channel containing the message * @param content - New content for the message * @returns Promise resolving when completed */ editMessage(messageId: string, channelId: string, content: string): Promise; /** * Deletes a message * * @param messageId - ID of the message to delete * @param channelId - ID of the channel containing the message * @returns Promise resolving when completed */ deleteMessage(messageId: string, channelId: string): Promise; /** * Sets the bot's status/activity * * @param status - Status to set (online, idle, dnd, invisible) * @param activity - Activity type (PLAYING, LISTENING, WATCHING, STREAMING, COMPETING) * @param name - Name of the activity * @returns Promise resolving when completed */ setStatus(status: 'online' | 'idle' | 'dnd' | 'invisible', activity: 'PLAYING' | 'LISTENING' | 'WATCHING' | 'STREAMING' | 'COMPETING', name: string): Promise; /** * Splits a message into chunks if it exceeds Discord's message length limit * * @param text - The text to split * @param max - Maximum length of each chunk (default: 2000) * @returns Array of message chunks */ private splitMessage; /** * Converts a Discord.js message to our internal format * * @param message - The message from Discord.js * @returns Converted message in our internal format */ private convertToDiscordMessage; }