11import type { Client } from "@buape/carbon" ;
2- import type { HistoryEntry } from "../../auto-reply/reply/history.js" ;
3- import type { ReplyToMode } from "../../config/config.js" ;
4- import type { RuntimeEnv } from "../../runtime.js" ;
5- import type { DiscordGuildEntryResolved } from "./allow-list.js" ;
62import type { DiscordMessageEvent , DiscordMessageHandler } from "./listeners.js" ;
3+ import type { DiscordMessagePreflightParams } from "./message-handler.preflight.types.js" ;
74import { hasControlCommand } from "../../auto-reply/command-detection.js" ;
85import {
96 createInboundDebouncer ,
@@ -14,29 +11,14 @@ import { preflightDiscordMessage } from "./message-handler.preflight.js";
1411import { processDiscordMessage } from "./message-handler.process.js" ;
1512import { resolveDiscordMessageText } from "./message-utils.js" ;
1613
17- type LoadedConfig = ReturnType < typeof import ( "../../config/config.js" ) . loadConfig > ;
18- type DiscordConfig = NonNullable <
19- import ( "../../config/config.js" ) . OpenClawConfig [ "channels" ]
20- > [ "discord" ] ;
14+ type DiscordMessageHandlerParams = Omit <
15+ DiscordMessagePreflightParams ,
16+ "ackReactionScope" | "groupPolicy" | "data" | "client"
17+ > ;
2118
22- export function createDiscordMessageHandler ( params : {
23- cfg : LoadedConfig ;
24- discordConfig : DiscordConfig ;
25- accountId : string ;
26- token : string ;
27- runtime : RuntimeEnv ;
28- botUserId ?: string ;
29- guildHistories : Map < string , HistoryEntry [ ] > ;
30- historyLimit : number ;
31- mediaMaxBytes : number ;
32- textLimit : number ;
33- replyToMode : ReplyToMode ;
34- dmEnabled : boolean ;
35- groupDmEnabled : boolean ;
36- groupDmChannels ?: Array < string | number > ;
37- allowFrom ?: Array < string | number > ;
38- guildEntries ?: Record < string , DiscordGuildEntryResolved > ;
39- } ) : DiscordMessageHandler {
19+ export function createDiscordMessageHandler (
20+ params : DiscordMessageHandlerParams ,
21+ ) : DiscordMessageHandler {
4022 const groupPolicy = params . discordConfig ?. groupPolicy ?? "open" ;
4123 const ackReactionScope = params . cfg . messages ?. ackReactionScope ?? "group-mentions" ;
4224 const debounceMs = resolveInboundDebounceMs ( { cfg : params . cfg , channel : "discord" } ) ;
0 commit comments