/** * Discord Integration for WORKWAY * * Bot and Webhook integration for Discord servers. * Zuhandenheit: Developer thinks "send message" not "POST to /channels/:id/messages" * * @example * ```typescript * import { Discord } from '@workwayco/integrations/discord'; * * // Bot integration (OAuth2 with bot scope) * const discord = new Discord({ botToken: process.env.DISCORD_BOT_TOKEN }); * * // Send a message * const message = await discord.channels.sendMessage({ * channelId: '123456789', * content: 'Hello from WORKWAY!' * }); * * // Send an embed * await discord.channels.sendMessage({ * channelId: '123456789', * embeds: [{ * title: 'New Issue Created', * description: 'Bug: Login not working', * color: 0xff0000 * }] * }); * ``` */ import { ActionResult, type StandardMessage, type StandardList } from '@workwayco/sdk'; import { BaseAPIClient } from '../core/base-client.js'; export interface DiscordUser { id: string; username: string; discriminator: string; global_name?: string; avatar?: string; bot?: boolean; system?: boolean; banner?: string; accent_color?: number; } export interface DiscordGuild { id: string; name: string; icon?: string; owner_id: string; permissions?: string; features: string[]; member_count?: number; description?: string; } export interface DiscordChannel { id: string; type: number; guild_id?: string; name?: string; topic?: string; position?: number; parent_id?: string; last_message_id?: string; } export interface DiscordEmbed { title?: string; description?: string; url?: string; timestamp?: string; color?: number; footer?: { text: string; icon_url?: string; }; image?: { url: string; }; thumbnail?: { url: string; }; author?: { name: string; url?: string; icon_url?: string; }; fields?: Array<{ name: string; value: string; inline?: boolean; }>; } export interface DiscordMessage { id: string; channel_id: string; guild_id?: string; author: DiscordUser; content: string; timestamp: string; edited_timestamp?: string; tts: boolean; mention_everyone: boolean; mentions: DiscordUser[]; attachments: Array<{ id: string; filename: string; url: string; size: number; }>; embeds: DiscordEmbed[]; type: number; } export interface DiscordRole { id: string; name: string; color: number; hoist: boolean; position: number; permissions: string; managed: boolean; mentionable: boolean; } export interface DiscordMember { user: DiscordUser; nick?: string; avatar?: string; roles: string[]; joined_at: string; premium_since?: string; pending?: boolean; } export declare const ChannelType: { readonly GUILD_TEXT: 0; readonly DM: 1; readonly GUILD_VOICE: 2; readonly GROUP_DM: 3; readonly GUILD_CATEGORY: 4; readonly GUILD_ANNOUNCEMENT: 5; readonly ANNOUNCEMENT_THREAD: 10; readonly PUBLIC_THREAD: 11; readonly PRIVATE_THREAD: 12; readonly GUILD_STAGE_VOICE: 13; readonly GUILD_DIRECTORY: 14; readonly GUILD_FORUM: 15; }; export interface DiscordConfig { /** Bot token (from Discord Developer Portal) */ botToken: string; /** Request timeout in ms (default: 30000) */ timeout?: number; } /** * Discord REST API client * * Zuhandenheit principles: * - Namespace-based API (channels, guilds, users) * - Consistent ActionResult pattern * - Embed helpers for rich messages */ export declare class Discord extends BaseAPIClient { constructor(config: DiscordConfig); /** * Override request to use Bot authorization */ protected request(path: string, options?: RequestInit, additionalHeaders?: Record, isRetry?: boolean): Promise; channels: { /** * Send a message to a channel */ sendMessage: (options: { channelId: string; content?: string; embeds?: DiscordEmbed[]; tts?: boolean; }) => Promise>; /** * Get a channel */ get: (channelId: string) => Promise>; /** * Get messages from a channel */ getMessages: (options: { channelId: string; limit?: number; before?: string; after?: string; around?: string; }) => Promise>>; /** * Edit a message */ editMessage: (options: { channelId: string; messageId: string; content?: string; embeds?: DiscordEmbed[]; }) => Promise>; /** * Delete a message */ deleteMessage: (options: { channelId: string; messageId: string; }) => Promise>; /** * Create a reaction on a message */ addReaction: (options: { channelId: string; messageId: string; emoji: string; }) => Promise>; }; guilds: { /** * Get a guild */ get: (guildId: string) => Promise>; /** * Get guild channels */ getChannels: (guildId: string) => Promise>; /** * Get guild members */ getMembers: (options: { guildId: string; limit?: number; after?: string; }) => Promise>>; /** * Get guild roles */ getRoles: (guildId: string) => Promise>; }; users: { /** * Get the current bot user */ me: () => Promise>; /** * Get the bot's guilds */ myGuilds: (options?: { limit?: number; before?: string; after?: string; }) => Promise>>; }; private handleError; } /** * Discord Webhook client for simple message sending without bot authentication * * @example * ```typescript * const webhook = new DiscordWebhook({ webhookUrl: 'https://discord.com/api/webhooks/...' }); * await webhook.send({ content: 'Hello!' }); * ``` */ export declare class DiscordWebhook { private readonly webhookUrl; constructor(options: { webhookUrl: string; }); /** * Send a message via webhook */ send(options: { content?: string; username?: string; avatar_url?: string; embeds?: DiscordEmbed[]; }): Promise>; } /** * Convert Discord message to StandardMessage */ export declare function toStandardMessage(message: DiscordMessage): StandardMessage; export default Discord; //# sourceMappingURL=index.d.ts.map