@elizaos/plugin-discord 2.0.0-alpha.4 → 2.0.0-alpha.537

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +549 -0
  3. package/dist/accounts.d.ts +164 -0
  4. package/dist/accounts.d.ts.map +1 -0
  5. package/dist/actions/actionResultSemantics.d.ts +9 -0
  6. package/dist/actions/actionResultSemantics.d.ts.map +1 -0
  7. package/dist/actions/chatWithAttachments.d.ts +4 -0
  8. package/dist/actions/chatWithAttachments.d.ts.map +1 -0
  9. package/dist/actions/createPoll.d.ts +4 -0
  10. package/dist/actions/createPoll.d.ts.map +1 -0
  11. package/dist/actions/deleteMessage.d.ts +4 -0
  12. package/dist/actions/deleteMessage.d.ts.map +1 -0
  13. package/dist/actions/downloadMedia.d.ts +4 -0
  14. package/dist/actions/downloadMedia.d.ts.map +1 -0
  15. package/dist/actions/editMessage.d.ts +4 -0
  16. package/dist/actions/editMessage.d.ts.map +1 -0
  17. package/dist/actions/getUserInfo.d.ts +4 -0
  18. package/dist/actions/getUserInfo.d.ts.map +1 -0
  19. package/dist/actions/joinChannel.d.ts +4 -0
  20. package/dist/actions/joinChannel.d.ts.map +1 -0
  21. package/dist/actions/leaveChannel.d.ts +4 -0
  22. package/dist/actions/leaveChannel.d.ts.map +1 -0
  23. package/dist/actions/listChannels.d.ts +4 -0
  24. package/dist/actions/listChannels.d.ts.map +1 -0
  25. package/dist/actions/pinMessage.d.ts +4 -0
  26. package/dist/actions/pinMessage.d.ts.map +1 -0
  27. package/dist/actions/reactToMessage.d.ts +4 -0
  28. package/dist/actions/reactToMessage.d.ts.map +1 -0
  29. package/dist/actions/readChannel.d.ts +4 -0
  30. package/dist/actions/readChannel.d.ts.map +1 -0
  31. package/dist/actions/searchMessages.d.ts +4 -0
  32. package/dist/actions/searchMessages.d.ts.map +1 -0
  33. package/dist/actions/sendDM.d.ts +4 -0
  34. package/dist/actions/sendDM.d.ts.map +1 -0
  35. package/dist/actions/sendMessage.d.ts +4 -0
  36. package/dist/actions/sendMessage.d.ts.map +1 -0
  37. package/dist/actions/serverInfo.d.ts +4 -0
  38. package/dist/actions/serverInfo.d.ts.map +1 -0
  39. package/dist/actions/setup-credentials.d.ts +25 -0
  40. package/dist/actions/setup-credentials.d.ts.map +1 -0
  41. package/dist/actions/summarizeConversation.d.ts +4 -0
  42. package/dist/actions/summarizeConversation.d.ts.map +1 -0
  43. package/dist/actions/transcribeMedia.d.ts +4 -0
  44. package/dist/actions/transcribeMedia.d.ts.map +1 -0
  45. package/dist/actions/unpinMessage.d.ts +4 -0
  46. package/dist/actions/unpinMessage.d.ts.map +1 -0
  47. package/dist/allowlist.d.ts +198 -0
  48. package/dist/allowlist.d.ts.map +1 -0
  49. package/dist/attachments.d.ts +93 -0
  50. package/dist/attachments.d.ts.map +1 -0
  51. package/dist/banner.d.ts +39 -0
  52. package/dist/banner.d.ts.map +1 -0
  53. package/dist/compat.d.ts +57 -0
  54. package/dist/compat.d.ts.map +1 -0
  55. package/dist/config.d.ts +156 -0
  56. package/dist/config.d.ts.map +1 -0
  57. package/dist/constants.d.ts +2 -0
  58. package/dist/constants.d.ts.map +1 -0
  59. package/dist/debouncer.d.ts +25 -0
  60. package/dist/debouncer.d.ts.map +1 -0
  61. package/dist/discord-commands.d.ts +16 -0
  62. package/dist/discord-commands.d.ts.map +1 -0
  63. package/dist/discord-events.d.ts +54 -0
  64. package/dist/discord-events.d.ts.map +1 -0
  65. package/dist/discord-history.d.ts +49 -0
  66. package/dist/discord-history.d.ts.map +1 -0
  67. package/dist/discord-interactions.d.ts +45 -0
  68. package/dist/discord-interactions.d.ts.map +1 -0
  69. package/dist/discord-local-service.d.ts +94 -0
  70. package/dist/discord-local-service.d.ts.map +1 -0
  71. package/dist/discord-reactions.d.ts +29 -0
  72. package/dist/discord-reactions.d.ts.map +1 -0
  73. package/dist/draft-chunking.d.ts +9 -0
  74. package/dist/draft-chunking.d.ts.map +1 -0
  75. package/dist/draft-stream.d.ts +23 -0
  76. package/dist/draft-stream.d.ts.map +1 -0
  77. package/dist/environment.d.ts +23 -0
  78. package/dist/environment.d.ts.map +1 -0
  79. package/dist/generated/prompts/typescript/prompts.d.ts +44 -0
  80. package/dist/generated/prompts/typescript/prompts.d.ts.map +1 -0
  81. package/dist/generated/specs/spec-helpers.d.ts +49 -0
  82. package/dist/generated/specs/spec-helpers.d.ts.map +1 -0
  83. package/dist/generated/specs/specs.d.ts +90 -0
  84. package/dist/generated/specs/specs.d.ts.map +1 -0
  85. package/dist/identity.d.ts +8 -0
  86. package/dist/identity.d.ts.map +1 -0
  87. package/dist/inbound-envelope.d.ts +8 -0
  88. package/dist/inbound-envelope.d.ts.map +1 -0
  89. package/dist/index.browser.d.ts +34 -0
  90. package/dist/index.browser.d.ts.map +1 -0
  91. package/dist/index.d.ts +19 -2
  92. package/dist/index.d.ts.map +1 -0
  93. package/dist/index.js +15379 -0
  94. package/dist/index.js.map +72 -0
  95. package/dist/messages.d.ts +62 -0
  96. package/dist/messages.d.ts.map +1 -0
  97. package/dist/messaging.d.ts +129 -0
  98. package/dist/messaging.d.ts.map +1 -0
  99. package/dist/native-commands.d.ts +142 -0
  100. package/dist/native-commands.d.ts.map +1 -0
  101. package/dist/owner-pairing-service.d.ts +73 -0
  102. package/dist/owner-pairing-service.d.ts.map +1 -0
  103. package/dist/permissionEvents.d.ts +42 -0
  104. package/dist/permissionEvents.d.ts.map +1 -0
  105. package/dist/permissions.d.ts +36 -0
  106. package/dist/permissions.d.ts.map +1 -0
  107. package/dist/profileSync.d.ts +8 -0
  108. package/dist/profileSync.d.ts.map +1 -0
  109. package/dist/providers/channelState.d.ts +14 -0
  110. package/dist/providers/channelState.d.ts.map +1 -0
  111. package/dist/providers/guildInfo.d.ts +15 -0
  112. package/dist/providers/guildInfo.d.ts.map +1 -0
  113. package/dist/providers/voiceState.d.ts +12 -0
  114. package/dist/providers/voiceState.d.ts.map +1 -0
  115. package/dist/reasoning-tags.d.ts +2 -0
  116. package/dist/reasoning-tags.d.ts.map +1 -0
  117. package/dist/service.d.ts +207 -0
  118. package/dist/service.d.ts.map +1 -0
  119. package/dist/setup-routes.d.ts +23 -0
  120. package/dist/setup-routes.d.ts.map +1 -0
  121. package/dist/slash-commands.d.ts +39 -0
  122. package/dist/slash-commands.d.ts.map +1 -0
  123. package/dist/status-reactions.d.ts +11 -0
  124. package/dist/status-reactions.d.ts.map +1 -0
  125. package/dist/test-setup.d.ts +1 -0
  126. package/dist/test-setup.d.ts.map +1 -0
  127. package/dist/tests.d.ts +123 -0
  128. package/dist/tests.d.ts.map +1 -0
  129. package/dist/types.d.ts +329 -0
  130. package/dist/types.d.ts.map +1 -0
  131. package/dist/typing.d.ts +7 -0
  132. package/dist/typing.d.ts.map +1 -0
  133. package/dist/utils.d.ts +48 -0
  134. package/dist/utils.d.ts.map +1 -0
  135. package/dist/vitest.config.d.ts +3 -0
  136. package/dist/vitest.config.d.ts.map +1 -0
  137. package/dist/voice.d.ts +234 -0
  138. package/dist/voice.d.ts.map +1 -0
  139. package/package.json +25 -20
@@ -0,0 +1,93 @@
1
+ import { type IAgentRuntime, type Media } from "@elizaos/core";
2
+ import { type Attachment, Collection } from "discord.js";
3
+ /**
4
+ * Class representing an Attachment Manager.
5
+ */
6
+ export declare class AttachmentManager {
7
+ private attachmentCache;
8
+ private runtime;
9
+ /**
10
+ * Constructor for creating a new instance of the class.
11
+ *
12
+ * @param {IAgentRuntime} runtime The runtime object to be injected into the instance.
13
+ */
14
+ constructor(runtime: IAgentRuntime);
15
+ private isImageDescriptionEnabled;
16
+ /**
17
+ * Processes attachments and returns an array of Media objects.
18
+ * @param {Collection<string, Attachment> | Attachment[]} attachments - The attachments to be processed
19
+ * @returns {Promise<Media[]>} - An array of processed Media objects
20
+ */
21
+ processAttachments(attachments: Collection<string, Attachment> | Attachment[]): Promise<Media[]>;
22
+ /**
23
+ * Processes the provided attachment to generate a media object.
24
+ * If the media for the attachment URL is already cached, it will return the cached media.
25
+ * Otherwise, it will determine the type of attachment (PDF, text, audio, video, image, generic)
26
+ * and call the corresponding processing method to generate the media object.
27
+ *
28
+ * @param attachment The attachment to process
29
+ * @returns A promise that resolves to a Media object representing the attachment, or null if the attachment could not be processed
30
+ */
31
+ processAttachment(attachment: Attachment): Promise<Media | null>;
32
+ /**
33
+ * Asynchronously processes an audio or video attachment provided as input and returns a Media object.
34
+ * @param {Attachment} attachment - The attachment object containing information about the audio/video file.
35
+ * @returns {Promise<Media>} A Promise that resolves to a Media object representing the processed audio/video attachment.
36
+ */
37
+ private processAudioVideoAttachment;
38
+ /**
39
+ * Extracts the audio stream from the provided MP4 data and converts it to MP3 format.
40
+ *
41
+ * @param {ArrayBuffer} mp4Data - The MP4 data to extract audio from
42
+ * @returns {Promise<Buffer>} - A Promise that resolves with the converted audio data as a Buffer
43
+ */
44
+ private extractAudioFromMP4;
45
+ /**
46
+ * Processes a PDF attachment by fetching the PDF file from the specified URL,
47
+ * converting it to text, generating a summary, and returning a Media object
48
+ * with the extracted information.
49
+ * If an error occurs during processing, a placeholder Media object is returned
50
+ * with an error message.
51
+ *
52
+ * @param {Attachment} attachment - The PDF attachment to process.
53
+ * @returns {Promise<Media>} A promise that resolves to a Media object representing
54
+ * the processed PDF attachment.
55
+ */
56
+ private processPdfAttachment;
57
+ /**
58
+ * Processes a plaintext attachment by fetching its content, generating a summary, and returning a Media object.
59
+ * @param {Attachment} attachment - The attachment object to process.
60
+ * @returns {Promise<Media>} A promise that resolves to a Media object representing the processed plaintext attachment.
61
+ */
62
+ private processPlaintextAttachment;
63
+ /**
64
+ * Process the image attachment by fetching description and title using the IMAGE_DESCRIPTION model.
65
+ * If successful, returns a Media object populated with the details. If unsuccessful, creates a fallback
66
+ * Media object and logs the error.
67
+ *
68
+ * @param {Attachment} attachment - The attachment object containing the image details.
69
+ * @returns {Promise<Media>} A promise that resolves to a Media object.
70
+ */
71
+ private processImageAttachment;
72
+ /**
73
+ * Creates a fallback Media object for image attachments that could not be recognized.
74
+ *
75
+ * @param {Attachment} attachment - The attachment object containing image details.
76
+ * @returns {Media} - The fallback Media object with basic information about the image attachment.
77
+ */
78
+ private createFallbackImageMedia;
79
+ /**
80
+ * Process a video attachment to extract video information.
81
+ * @param {Attachment} attachment - The attachment object containing video information.
82
+ * @returns {Promise<Media>} A promise that resolves to a Media object with video details.
83
+ * @throws {Error} If video service is not available.
84
+ */
85
+ private processVideoAttachment;
86
+ /**
87
+ * Process a generic attachment and return a Media object with specified properties.
88
+ * @param {Attachment} attachment - The attachment object to process.
89
+ * @returns {Promise<Media>} A Promise that resolves to a Media object with specified properties.
90
+ */
91
+ private processGenericAttachment;
92
+ }
93
+ //# sourceMappingURL=attachments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachments.d.ts","sourceRoot":"","sources":["../attachments.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,KAAK,EAIV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAIzD;;GAEG;AACH,qBAAa,iBAAiB;IAC7B,OAAO,CAAC,eAAe,CAAiC;IACxD,OAAO,CAAC,OAAO,CAAgB;IAE/B;;;;OAIG;gBACS,OAAO,EAAE,aAAa;IAIlC,OAAO,CAAC,yBAAyB;IAejC;;;;OAIG;IACG,kBAAkB,CACvB,WAAW,EAAE,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,UAAU,EAAE,GACxD,OAAO,CAAC,KAAK,EAAE,CAAC;IAiBnB;;;;;;;;OAQG;IACG,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAqCtE;;;;OAIG;YACW,2BAA2B;IAqIzC;;;;;OAKG;YACW,mBAAmB;IAwGjC;;;;;;;;;;OAUG;YACW,oBAAoB;IAqDlC;;;;OAIG;YACW,0BAA0B;IAgDxC;;;;;;;OAOG;YACW,sBAAsB;IA2CpC;;;;;OAKG;IAEH,OAAO,CAAC,wBAAwB;IAWhC;;;;;OAKG;YACW,sBAAsB;IAsDpC;;;;OAIG;YACW,wBAAwB;CAYtC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Discord Plugin Settings Banner
3
+ * Beautiful ANSI art display for configuration on startup
4
+ * Includes tiered permission system for invite URLs
5
+ */
6
+ import type { IAgentRuntime } from "@elizaos/core";
7
+ import { type DiscordPermissionValues } from "./permissions";
8
+ export interface PluginSetting {
9
+ name: string;
10
+ value: unknown;
11
+ defaultValue?: unknown;
12
+ sensitive?: boolean;
13
+ required?: boolean;
14
+ }
15
+ export interface BannerOptions {
16
+ pluginName: string;
17
+ description?: string;
18
+ settings: PluginSetting[];
19
+ runtime: IAgentRuntime;
20
+ /** Discord Application ID for generating invite URLs */
21
+ applicationId?: string;
22
+ /** Permission values for the 3x2 tier matrix */
23
+ discordPermissions?: DiscordPermissionValues;
24
+ }
25
+ /**
26
+ * Render a framed ANSI banner that displays plugin settings and, when available, tiered Discord invite URLs.
27
+ *
28
+ * The banner lists each setting with masked or truncated values, a status (custom/default/unset/required),
29
+ * and an optional Discord invite section generated from `applicationId` and `discordPermissions`.
30
+ *
31
+ * @param options - Configuration for the banner, including `settings`, the `runtime` used to emit the banner,
32
+ * and optional Discord invite data (`applicationId`, `discordPermissions`).
33
+ */
34
+ export declare function printBanner(options: BannerOptions): void;
35
+ /**
36
+ * Print the Discord plugin banner with current settings.
37
+ */
38
+ export declare function printDiscordBanner(runtime: IAgentRuntime): void;
39
+ //# sourceMappingURL=banner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../banner.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EACN,KAAK,uBAAuB,EAE5B,MAAM,eAAe,CAAC;AAgBvB,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,OAAO,EAAE,aAAa,CAAC;IACvB,wDAAwD;IACxD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gDAAgD;IAChD,kBAAkB,CAAC,EAAE,uBAAuB,CAAC;CAC7C;AAoFD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAoIxD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CA6C/D"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Runtime compatibility layer for old/new core.
3
+ *
4
+ * Automatically adds serverId when messageServerId is provided,
5
+ * making plugin code work with both core versions unchanged.
6
+ *
7
+ * Old core expects: serverId (string)
8
+ * New core expects: messageServerId (UUID)
9
+ *
10
+ * NOTE: UUID function usage for Discord IDs:
11
+ * - `stringToUuid(str)` - CONVERTS any string to a deterministic UUID by hashing.
12
+ * Use this for Discord snowflake IDs (always succeeds, same input = same output).
13
+ * - `asUUID(str)` - VALIDATES that string is already a valid UUID format.
14
+ * Throws if not a valid UUID. Only use when input is already a UUID.
15
+ *
16
+ * REMOVAL: Delete this file and remove createCompatRuntime() call in service.ts
17
+ */
18
+ import type { ChannelType, Entity, IAgentRuntime, Metadata, Room, UUID, World } from "@elizaos/core";
19
+ /**
20
+ * Extended types that support messageServerId for cross-core compatibility.
21
+ * These allow TypeScript to accept messageServerId in object literals.
22
+ */
23
+ export type WorldCompat = Omit<World, "serverId"> & {
24
+ serverId?: string;
25
+ messageServerId?: UUID;
26
+ };
27
+ export type RoomCompat = Omit<Room, "serverId"> & {
28
+ serverId?: string;
29
+ messageServerId?: UUID;
30
+ };
31
+ export interface EnsureConnectionParams {
32
+ entityId: UUID;
33
+ roomId: UUID;
34
+ roomName?: string;
35
+ userName?: string;
36
+ name?: string;
37
+ worldName?: string;
38
+ source?: string;
39
+ channelId?: string;
40
+ serverId?: string;
41
+ messageServerId?: UUID;
42
+ type?: ChannelType | string;
43
+ worldId?: UUID;
44
+ userId?: UUID;
45
+ metadata?: Metadata;
46
+ }
47
+ /**
48
+ * Extended runtime interface that accepts messageServerId in method parameters.
49
+ */
50
+ export interface ICompatRuntime extends Omit<IAgentRuntime, "ensureWorldExists" | "ensureRoomExists" | "ensureConnection" | "ensureConnections"> {
51
+ ensureWorldExists(world: WorldCompat): Promise<void>;
52
+ ensureRoomExists(room: RoomCompat): Promise<void>;
53
+ ensureConnection(params: EnsureConnectionParams): Promise<void>;
54
+ ensureConnections(entities: Entity[], rooms: RoomCompat[], source: string, world: WorldCompat): Promise<void>;
55
+ }
56
+ export declare function createCompatRuntime(runtime: IAgentRuntime): ICompatRuntime;
57
+ //# sourceMappingURL=compat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compat.d.ts","sourceRoot":"","sources":["../compat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EACX,WAAW,EACX,MAAM,EACN,aAAa,EACb,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,MAAM,eAAe,CAAC;AAEvB;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,GAAG;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,IAAI,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,EAAE,UAAU,C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@@
1
+ /**
2
+ * Discord plugin configuration types.
3
+ *
4
+ * These types define the configuration schema for the Discord plugin.
5
+ * Shared base types are imported from @elizaos/core.
6
+ */
7
+ import type { BlockStreamingCoalesceConfig, ChannelHeartbeatVisibilityConfig, DmConfig, DmPolicy, GroupPolicy, GroupToolPolicyBySenderConfig, GroupToolPolicyConfig, MarkdownConfig, OutboundRetryConfig, ProviderCommandsConfig, ReplyToMode } from "@elizaos/core";
8
+ export type DiscordPluralKitConfig = {
9
+ enabled?: boolean;
10
+ detectProxied?: boolean;
11
+ cacheUsers?: boolean;
12
+ };
13
+ export type DiscordDmConfig = {
14
+ /** If false, ignore all incoming Discord DMs. Default: true. */
15
+ enabled?: boolean;
16
+ /** Direct message access policy (default: pairing). */
17
+ policy?: DmPolicy;
18
+ /** Allowlist for DM senders (ids or names). */
19
+ allowFrom?: Array<string | number>;
20
+ /** If true, allow group DMs (default: false). */
21
+ groupEnabled?: boolean;
22
+ /** Optional allowlist for group DM channels (ids or slugs). */
23
+ groupChannels?: Array<string | number>;
24
+ };
25
+ export type DiscordGuildChannelConfig = {
26
+ allow?: boolean;
27
+ requireMention?: boolean;
28
+ /** Optional tool policy overrides for this channel. */
29
+ tools?: GroupToolPolicyConfig;
30
+ toolsBySender?: GroupToolPolicyBySenderConfig;
31
+ /** If specified, only load these skills for this channel. Omit = all skills; empty = no skills. */
32
+ skills?: string[];
33
+ /** If false, disable the bot for this channel. */
34
+ enabled?: boolean;
35
+ /** Optional allowlist for channel senders (ids or names). */
36
+ users?: Array<string | number>;
37
+ /** Optional system prompt snippet for this channel. */
38
+ systemPrompt?: string;
39
+ };
40
+ export type DiscordReactionNotificationMode = "off" | "own" | "all" | "allowlist";
41
+ export type DiscordGuildEntry = {
42
+ slug?: string;
43
+ requireMention?: boolean;
44
+ /** Optional tool policy overrides for this guild (used when channel override is missing). */
45
+ tools?: GroupToolPolicyConfig;
46
+ toolsBySender?: GroupToolPolicyBySenderConfig;
47
+ /** Reaction notification mode (off|own|all|allowlist). Default: own. */
48
+ reactionNotifications?: DiscordReactionNotificationMode;
49
+ users?: Array<string | number>;
50
+ channels?: Record<string, DiscordGuildChannelConfig>;
51
+ };
52
+ export type DiscordActionConfig = {
53
+ reactions?: boolean;
54
+ stickers?: boolean;
55
+ polls?: boolean;
56
+ permissions?: boolean;
57
+ messages?: boolean;
58
+ threads?: boolean;
59
+ pins?: boolean;
60
+ search?: boolean;
61
+ memberInfo?: boolean;
62
+ roleInfo?: boolean;
63
+ roles?: boolean;
64
+ channelInfo?: boolean;
65
+ voiceStatus?: boolean;
66
+ events?: boolean;
67
+ moderation?: boolean;
68
+ emojiUploads?: boolean;
69
+ stickerUploads?: boolean;
70
+ channels?: boolean;
71
+ /** Enable bot presence/activity changes (default: false). */
72
+ presence?: boolean;
73
+ };
74
+ export type DiscordIntentsConfig = {
75
+ /** Enable Guild Presences privileged intent (requires Portal opt-in). Default: false. */
76
+ presence?: boolean;
77
+ /** Enable Guild Members privileged intent (requires Portal opt-in). Default: false. */
78
+ guildMembers?: boolean;
79
+ };
80
+ export type DiscordExecApprovalConfig = {
81
+ /** Enable exec approval forwarding to Discord DMs. Default: false. */
82
+ enabled?: boolean;
83
+ /** Discord user IDs to receive approval prompts. Required if enabled. */
84
+ approvers?: Array<string | number>;
85
+ /** Only forward approvals for these agent IDs. Omit = all agents. */
86
+ agentFilter?: string[];
87
+ /** Only forward approvals matching these session key patterns (substring or regex). */
88
+ sessionFilter?: string[];
89
+ };
90
+ export type DiscordAccountConfig = {
91
+ /** Optional display name for this account (used in CLI/UI lists). */
92
+ name?: string;
93
+ /** Optional provider capability tags used for agent/runtime guidance. */
94
+ capabilities?: string[];
95
+ /** Markdown formatting overrides (tables). */
96
+ markdown?: MarkdownConfig;
97
+ /** Override native command registration for Discord (bool or "auto"). */
98
+ commands?: ProviderCommandsConfig;
99
+ /** Allow channel-initiated config writes (default: true). */
100
+ configWrites?: boolean;
101
+ /** If false, do not start this Discord account. Default: true. */
102
+ enabled?: boolean;
103
+ token?: string;
104
+ /** Allow bot-authored messages to trigger replies (default: false). */
105
+ allowBots?: boolean;
106
+ /**
107
+ * Controls how guild channel messages are handled:
108
+ * - "open": guild channels bypass allowlists; mention-gating applies
109
+ * - "disabled": block all guild channel messages
110
+ * - "allowlist": only allow channels present in discord.guilds.*.channels
111
+ */
112
+ groupPolicy?: GroupPolicy;
113
+ /** Outbound text chunk size (chars). Default: 2000. */
114
+ textChunkLimit?: number;
115
+ /** Chunking mode: "length" (default) splits by size; "newline" splits on every newline. */
116
+ chunkMode?: "length" | "newline";
117
+ /** Disable block streaming for this account. */
118
+ blockStreaming?: boolean;
119
+ /** Merge streamed block replies before sending. */
120
+ blockStreamingCoalesce?: BlockStreamingCoalesceConfig;
121
+ /**
122
+ * Soft max line count per Discord message.
123
+ * Discord clients can clip/collapse very tall messages; splitting by lines
124
+ * keeps replies readable in-channel. Default: 17.
125
+ */
126
+ maxLinesPerMessage?: number;
127
+ mediaMaxMb?: number;
128
+ historyLimit?: number;
129
+ /** Max DM turns to keep as history context. */
130
+ dmHistoryLimit?: number;
131
+ /** Per-DM config overrides keyed by user ID. */
132
+ dms?: Record<string, DmConfig>;
133
+ /** Retry policy for outbound Discord API calls. */
134
+ retry?: OutboundRetryConfig;
135
+ /** Per-action tool gating (default: true for all). */
136
+ actions?: DiscordActionConfig;
137
+ /** Control reply threading when reply tags are present (off|first|all). */
138
+ replyToMode?: ReplyToMode;
139
+ dm?: DiscordDmConfig;
140
+ /** New per-guild config keyed by guild id or slug. */
141
+ guilds?: Record<string, DiscordGuildEntry>;
142
+ /** Heartbeat visibility settings for this channel. */
143
+ heartbeat?: ChannelHeartbeatVisibilityConfig;
144
+ /** Exec approval forwarding configuration. */
145
+ execApprovals?: DiscordExecApprovalConfig;
146
+ /** Privileged Gateway Intents (must also be enabled in Discord Developer Portal). */
147
+ intents?: DiscordIntentsConfig;
148
+ /** PluralKit identity resolution for proxied messages. */
149
+ pluralkit?: DiscordPluralKitConfig;
150
+ };
151
+ export type DiscordChannelConfig = {
152
+ /** Optional per-account Discord configuration (multi-account). */
153
+ accounts?: Record<string, DiscordAccountConfig>;
154
+ } & DiscordAccountConfig;
155
+ export type { DiscordChannelConfig as DiscordConfig };
156
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACX,4BAA4B,EAC5B,gCAAgC,EAChC,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,6BAA6B,EAC7B,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,sBAAsB,EACtB,WAAW,EACX,MAAM,eAAe,CAAC;AAMvB,MAAM,MAAM,sBAAsB,GAAG;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAMF,MAAM,MAAM,eAAe,GAAG;IAC7B,gEAAgE;IAChE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uDAAuD;IACvD,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IACnC,iDAAiD;IACjD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,+DAA+D;IAC/D,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;CACvC,CAAC;AAMF,MAAM,MAAM,yBAAyB,GAAG;IACvC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,uDAAuD;IACvD,KAAK,CAAC,EAAE,qBAAqB,CAAC;IAC9B,aAAa,CAAC,EAAE,6BAA6B,CAAC;IAC9C,mGAAmG;IACnG,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,kDAAkD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gD;IAChD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mDAAmD;IACnD,sBAAsB,CAAC,EAAE,4BAA4B,CAAC;IACtD;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+CAA+C;IAC/C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gDAAgD;IAChD,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC/B,mDAAmD;IACnD,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,sDAAsD;IACtD,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,2EAA2E;IAC3E,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,EAAE,CAAC,EAAE,eAAe,CAAC;IACrB,sDAAsD;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC3C,sDAAsD;IACtD,SAAS,CAAC,EAAE,gCAAgC,CAAC;IAC7C,8CAA8C;IAC9C,aAAa,CAAC,EAAE,yBAAyB,CAAC;IAC1C,qFAAqF;IACrF,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,0DAA0D;IAC1D,SAAS,CAAC,EAAE,sBAAsB,CAAC;CACnC,CAAC;AAMF,MAAM,MAAM,oBAAoB,GAAG;IAClC,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;CAChD,GAAG,oBAAoB,CAAC;AAGzB,YAAY,EAAE,oBAAoB,IAAI,aAAa,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const DISCORD_SERVICE_NAME = "discord";
2
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,YAAY,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { Message as DiscordMessage } from "discord.js";
2
+ export type DebouncerFlushCallback = (messages: DiscordMessage[]) => void;
3
+ export interface MessageDebouncer {
4
+ enqueue: (message: DiscordMessage) => void;
5
+ flushAll: () => void;
6
+ pendingCount: () => number;
7
+ destroy: () => void;
8
+ }
9
+ export interface ChannelDebouncerOptions {
10
+ debounceMs?: number;
11
+ responseCooldownMs?: number;
12
+ botUserId?: string;
13
+ getBotUserId?: () => string | undefined;
14
+ botName?: string;
15
+ }
16
+ export interface ChannelDebouncer {
17
+ enqueue: (message: DiscordMessage) => void;
18
+ markResponded: (channelId: string) => void;
19
+ flushAll: () => void;
20
+ pendingCount: () => number;
21
+ destroy: () => void;
22
+ }
23
+ export declare function createChannelDebouncer(onFlush: DebouncerFlushCallback, options?: ChannelDebouncerOptions): ChannelDebouncer;
24
+ export declare function createMessageDebouncer(onFlush: DebouncerFlushCallback, debounceMs?: number): MessageDebouncer;
25
+ //# sourceMappingURL=debouncer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debouncer.d.ts","sourceRoot":"","sources":["../debouncer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5D,MAAM,MAAM,sBAAsB,GAAG,CAAC,QAAQ,EAAE,cAAc,EAAE,KAAK,IAAI,CAAC;AAE1E,MAAM,WAAW,gBAAgB;IAChC,OAAO,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;IAC3C,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,OAAO,EAAE,MAAM,IAAI,CAAC;CACpB;AAsBD,MAAM,WAAW,uBAAuB;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAChC,OAAO,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;IAC3C,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,OAAO,EAAE,MAAM,IAAI,CAAC;CACpB;AAOD,wBAAgB,sBAAsB,CACrC,OAAO,EAAE,sBAAsB,EAC/B,OAAO,GAAE,uBAA4B,GACnC,gBAAgB,CA8GlB;AAED,wBAAgB,sBAAsB,CACrC,OAAO,EAAE,sBAAsB,EAC/B,UAAU,GAAE,MAA4B,GACtC,gBAAgB,CAsElB"}
@@ -0,0 +1,16 @@
1
+ import type { ApplicationCommandDataResolvable, Guild } from "discord.js";
2
+ import type { InteractionServiceInternals } from "./discord-interactions";
3
+ import type { DiscordSlashCommand } from "./types";
4
+ /**
5
+ * Transforms an ElizaOS slash command to Discord API format.
6
+ */
7
+ export declare function transformCommandToDiscordApi(cmd: DiscordSlashCommand): ApplicationCommandDataResolvable;
8
+ /**
9
+ * Checks if a command is guild-only.
10
+ */
11
+ export declare function isGuildOnlyCommand(cmd: DiscordSlashCommand): boolean;
12
+ /**
13
+ * Handles the event when the bot joins a guild.
14
+ */
15
+ export declare function handleGuildCreate(service: InteractionServiceInternals, guild: Guild): Promise<void>;
16
+ //# sourceMappingURL=discord-commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discord-commands.d.ts","sourceRoot":"","sources":["../discord-commands.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACX,gCAAgC,EAEhC,KAAK,EACL,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAM1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAGnD;;GAEG;AACH,wBAAgB,4BAA4B,CAC3C,GAAG,EAAE,mBAAmB,GACtB,gCAAgC,CAwBlC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAKpE;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACtC,OAAO,EAAE,2BAA2B,EACpC,KAAK,EAAE,KAAK,GACV,OAAO,CAAC,IAAI,CAAC,CAwFf"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Discord event listener setup — extracted from service.ts
3
+ *
4
+ * Contains the body of `setupEventListeners()`: all `client.on(...)` registrations
5
+ * for messageCreate, reactions, guild events, interactions, voice streams,
6
+ * and permission audit events.
7
+ */
8
+ import { type ChannelType as ElizaChannelType, type UUID } from "@elizaos/core";
9
+ import { type Channel, type GuildMember, type Interaction, type Message, type User } from "discord.js";
10
+ import { type ChannelDebouncer, type MessageDebouncer } from "./debouncer";
11
+ import type { DiscordService } from "./service";
12
+ import { type DiscordSlashCommand } from "./types";
13
+ /**
14
+ * Subset of DiscordService fields needed by the event listeners.
15
+ * Because many of the relevant fields are private, the caller passes
16
+ * `this as unknown as DiscordServiceInternals`.
17
+ */
18
+ export interface DiscordServiceInternals {
19
+ client: NonNullable<DiscordService["client"]>;
20
+ runtime: DiscordService["runtime"];
21
+ character: DiscordService["character"];
22
+ messageManager: DiscordService["messageManager"];
23
+ voiceManager: DiscordService["voiceManager"];
24
+ messageDebouncer: MessageDebouncer | undefined;
25
+ channelDebouncer: ChannelDebouncer | undefined;
26
+ discordSettings: {
27
+ shouldIgnoreBotMessages: boolean;
28
+ };
29
+ allowedChannelIds: string[] | undefined;
30
+ allowAllSlashCommands: Set<string>;
31
+ slashCommands: DiscordSlashCommand[];
32
+ timeouts: ReturnType<typeof setTimeout>[];
33
+ userSelections: Map<string, Record<string, unknown>>;
34
+ isChannelAllowed(channelId: string): boolean;
35
+ resolveDiscordEntityId(userId: string): UUID;
36
+ buildMemoryFromMessage(message: Message): Promise<import("@elizaos/core").Memory | null>;
37
+ getChannelType(channel: Channel): Promise<ElizaChannelType>;
38
+ handleInteractionCreate(interaction: Interaction): Promise<void>;
39
+ handleGuildCreate(guild: import("discord.js").Guild): Promise<void>;
40
+ handleGuildMemberAdd(member: GuildMember): Promise<void>;
41
+ handleReactionAdd(reaction: import("discord.js").MessageReaction | import("discord.js").PartialMessageReaction, user: User | import("discord.js").PartialUser): Promise<void>;
42
+ handleReactionRemove(reaction: import("discord.js").MessageReaction | import("discord.js").PartialMessageReaction, user: User | import("discord.js").PartialUser): Promise<void>;
43
+ }
44
+ /**
45
+ * Wire up all Discord.js event listeners on `service.client`.
46
+ *
47
+ * Returns the created debouncers so the caller can store them on the service
48
+ * instance (they must be destroyed on stop).
49
+ */
50
+ export declare function setupDiscordEventListeners(service: DiscordServiceInternals): {
51
+ messageDebouncer: MessageDebouncer;
52
+ channelDebouncer: ChannelDebouncer;
53
+ };
54
+ //# sourceMappingURL=discord-events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discord-events.d.ts","sourceRoot":"","sources":["../discord-events.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAEN,KAAK,WAAW,IAAI,gBAAgB,EAEpC,KAAK,IAAI,EACT,MAAM,eAAe,CAAC;AACvB,OAAO,EAEN,KAAK,OAAO,EAIZ,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,IAAI,EACT,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,KAAK,gBAAgB,EAGrB,KAAK,gBAAgB,EACrB,MAAM,aAAa,CAAC;AAOrB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAKhD,OAAO,EAIN,KAAK,mBAAmB,EACxB,MAAM,SAAS,CAAC;AAEjB;;;;GAIG;AACH,MAAM,WAAW,uBAAu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CAAC,IAAI,CAAC,CAAC;IACzD,iBAAiB,CAChB,QAAQ,EACL,OAAO,YAAY,EAAE,eAAe,GACpC,OAAO,YAAY,EAAE,sBAAsB,EAC9C,IAAI,EAAE,IAAI,GAAG,OAAO,YAAY,EAAE,WAAW,GAC3C,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,oBAAoB,CACnB,QAAQ,EACL,OAAO,YAAY,EAAE,eAAe,GACpC,OAAO,YAAY,EAAE,sBAAsB,EAC9C,IAAI,EAAE,IAAI,GAAG,OAAO,YAAY,EAAE,WAAW,GAC3C,OAAO,CAAC,IAAI,CAAC,CAAC;CACjB;AAgED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,uBAAuB,GAAG;IAC7E,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,gBAAgB,EAAE,gBAAgB,CAAC;CACnC,CA40BA"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Discord message history / spidering — extracted from service.ts
3
+ *
4
+ * Contains fetchChannelHistory(), getSpiderState(), saveSpiderState(),
5
+ * buildMemoryFromMessage(), ensureConnectionsForMessages().
6
+ */
7
+ import { ChannelType, type Media, type Memory, type UUID } from "@elizaos/core";
8
+ import type { Channel, GuildTextBasedChannel, Message } from "discord.js";
9
+ import type { ICompatRuntime } from "./compat";
10
+ import type { MessageManager } from "./messages";
11
+ import type { DiscordService } from "./service";
12
+ import type { ChannelHistoryOptions, ChannelHistoryResult, ChannelSpiderState } from "./types";
13
+ /**
14
+ * Subset of DiscordService fields needed by history functions.
15
+ */
16
+ export interface HistoryServiceInternals {
17
+ client: NonNullable<DiscordService["client"]>;
18
+ runtime: ICompatRuntime;
19
+ messageManager: MessageManager | undefined;
20
+ resolveDiscordEntityId(userId: string): UUID;
21
+ getChannelType(channel: Channel): Promise<ChannelType>;
22
+ isGuildTextBasedChannel(channel: Channel | null): channel is GuildTextBasedChannel;
23
+ }
24
+ /**
25
+ * Get spider state for a channel from the database.
26
+ */
27
+ export declare function getSpiderState(service: HistoryServiceInternals, channelId: string): Promise<ChannelSpiderState | null>;
28
+ /**
29
+ * Save spider state for a channel to the database.
30
+ */
31
+ export declare function saveSpiderState(service: HistoryServiceInternals, state: ChannelSpiderState): Promise<void>;
32
+ /**
33
+ * Builds a Memory object from a Discord Message.
34
+ */
35
+ export declare function buildMemoryFromMessage(service: HistoryServiceInternals, message: Message, options?: {
36
+ processedContent?: string;
37
+ processedAttachments?: Media[];
38
+ extraContent?: Record<string, unknown>;
39
+ extraMetadata?: Record<string, unknown>;
40
+ }): Promise<Memory | null>;
41
+ /**
42
+ * Ensures entity connections exist for a batch of Discord messages using batch API.
43
+ */
44
+ export declare function ensureConnectionsForMessages(service: HistoryServiceInternals, messages: Message[], ensuredEntityIds?: Set<string>): Promise<void>;
45
+ /**
46
+ * Fetches and persists message history from a Discord channel.
47
+ */
48
+ export declare function fetchChannelHistory(service: HistoryServiceInternals, channelId: string, options?: ChannelHistoryOptions): Promise<ChannelHistoryResult>;
49
+ //# sourceMappingURL=discord-history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discord-history.d.ts","sourceRoot":"","sources":["../discord-history.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACN,WAAW,EAGX,KAAK,KAAK,EACV,KAAK,MAAM,EAGX,KAAK,IAAI,EACT,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,UAAU,CAAC;AAK5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EACX,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,MAAM,E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AAE,MAAM,EACjB,OAAO,GAAE,qBAA0B,GACjC,OAAO,CAAC,oBAAoB,CAAC,CAqjB/B"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Discord interaction handling — extracted from service.ts
3
+ *
4
+ * Contains handleInteractionCreate(), buildStandardizedRooms(),
5
+ * buildStandardizedUsers(), and onReady().
6
+ */
7
+ import { ChannelType, type Entity, type Room, type UUID } from "@elizaos/core";
8
+ import { type Channel, type Guild, type Interaction } from "discord.js";
9
+ import type { ICompatRuntime } from "./compat";
10
+ import type { DiscordService } from "./service";
11
+ import { type DiscordSettings, type DiscordSlashCommand } from "./types";
12
+ /**
13
+ * Subset of DiscordService fields needed by interaction handling.
14
+ */
15
+ export interface InteractionServiceInternals {
16
+ client: NonNullable<DiscordService["client"]>;
17
+ runtime: ICompatRuntime;
18
+ character: DiscordService["character"];
19
+ slashCommands: DiscordSlashCommand[];
20
+ userSelections: Map<string, Record<string, unknown>>;
21
+ timeouts: ReturnType<typeof setTimeout>[];
22
+ discordSettings: DiscordSettings;
23
+ clientReadyPromise: Promise<void> | null;
24
+ resolveDiscordEntityId(userId: string): UUID;
25
+ getChannelType(channel: Channel): Promise<ChannelType>;
26
+ registerSlashCommands(commands: DiscordSlashCommand[]): Promise<void>;
27
+ refreshOwnerDiscordUserIds(client: unknown): Promise<void>;
28
+ }
29
+ /**
30
+ * Handles interactions created by the user (commands, message components).
31
+ */
32
+ export declare function handleInteractionCreate(service: InteractionServiceInternals, interaction: Interaction): Promise<void>;
33
+ /**
34
+ * Builds a standardized list of rooms from Discord guild channels.
35
+ */
36
+ export declare function buildStandardizedRooms(service: InteractionServiceInternals, guild: Guild, _worldId: UUID): Promise<Room[]>;
37
+ /**
38
+ * Builds a standardized list of users (entities) from Discord guild members.
39
+ */
40
+ export declare function buildStandardizedUsers(service: InteractionServiceInternals, guild: Guild): Promise<Entity[]>;
41
+ /**
42
+ * Handles tasks to be performed once the Discord client is fully ready.
43
+ */
44
+ export declare function onReady(service: InteractionServiceInternals, readyClient: any): Promise<void>;
45
+ //# sourceMappingURL=discord-interactions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discord-interactions.d.ts","sourceRoot":"","sources":["../discord-interactions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACN,WAAW,EAEX,KAAK,MAAM,EAGX,KAAK,IAAI,EAET,KAAK,IAAI,EAET,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,KAAK,OAAO,EAEZ,KAAK,KAAK,EAEV,KAAK,WAAW,EAGhB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAO/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAGN,KAAK,eAAe,EACpB,KAAK,mBAAmB,EAExB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC3C,MAAM,EAAE,WAAW,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC9C,OAAO,EAAE,cAAc,CAAC;IACxB,SAAS,EAAE,cAAc,CAAC,WAAW,CAAC,CAAC;IACvC,aAAa,EAAE,mBAAmB,EAAE,CAAC;IACrC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACrD,QAAQ,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,EAAE,CAAC;IAC1C,eAAe,EAAE,eAAe,CAAC;IACjC,kBAAkB,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAEzC,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACvD,qBAAqB,CAAC,QAAQ,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC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