11import { DEFAULT_ACCOUNT_ID , normalizeAccountId } from "openclaw/plugin-sdk/account-id" ;
22import { listCombinedAccountIds } from "openclaw/plugin-sdk/account-resolution" ;
33import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts" ;
4- import {
5- hasConfiguredSecretInput ,
6- normalizeSecretInputString ,
7- } from "openclaw/plugin-sdk/secret-input" ;
4+ import { inspectDiscordConfiguredToken } from "./account-token-inspect.js" ;
85import { resolveDefaultDiscordAccountId } from "./accounts.js" ;
96import { mergeDiscordAccountConfig , resolveDiscordAccountConfig } from "./accounts.js" ;
107import type { DiscordAccountConfig } from "./runtime-api.js" ;
@@ -20,29 +17,6 @@ type InspectedDiscordSetupAccount = {
2017 config : DiscordAccountConfig ;
2118} ;
2219
23- function inspectConfiguredToken ( value : unknown ) : {
24- token : string ;
25- tokenSource : "config" ;
26- tokenStatus : "available" | "configured_unavailable" ;
27- } | null {
28- const normalized = normalizeSecretInputString ( value ) ;
29- if ( normalized ) {
30- return {
31- token : normalized . replace ( / ^ B o t \s + / i, "" ) ,
32- tokenSource : "config" ,
33- tokenStatus : "available" ,
34- } ;
35- }
36- if ( hasConfiguredSecretInput ( value ) ) {
37- return {
38- token : "" ,
39- tokenSource : "config" ,
40- tokenStatus : "configured_unavailable" ,
41- } ;
42- }
43- return null ;
44- }
45-
4620export function listDiscordSetupAccountIds ( cfg : OpenClawConfig ) : string [ ] {
4721 const accounts = cfg . channels ?. discord ?. accounts ;
4822 return listCombinedAccountIds ( {
@@ -82,7 +56,7 @@ export function inspectDiscordSetupAccount(params: {
8256 accountConfig &&
8357 Object . prototype . hasOwnProperty . call ( accountConfig as Record < string , unknown > , "token" ) ,
8458 ) ;
85- const accountToken = inspectConfiguredToken ( accountConfig ?. token ) ;
59+ const accountToken = inspectDiscordConfiguredToken ( accountConfig ?. token ) ;
8660 if ( accountToken ) {
8761 return {
8862 accountId,
@@ -106,7 +80,7 @@ export function inspectDiscordSetupAccount(params: {
10680 } ;
10781 }
10882
109- const channelToken = inspectConfiguredToken ( params . cfg . channels ?. discord ?. token ) ;
83+ const channelToken = inspectDiscordConfiguredToken ( params . cfg . channels ?. discord ?. token ) ;
11084 if ( channelToken ) {
11185 return {
11286 accountId,
0 commit comments