mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 16:10:49 +00:00
refactor: trim discord helper exports
This commit is contained in:
@@ -160,7 +160,7 @@ function resolveDiscordAccountTokenOwner(params: {
|
||||
return owner?.accountId;
|
||||
}
|
||||
|
||||
export function resolveDiscordDuplicateTokenOwner(params: {
|
||||
function resolveDiscordDuplicateTokenOwner(params: {
|
||||
cfg: OpenClawConfig;
|
||||
account: ResolvedDiscordAccount;
|
||||
}): string | undefined {
|
||||
|
||||
@@ -121,7 +121,7 @@ function getDiscordApiRetryAfterMs(
|
||||
return Math.min(Math.max(0, err.retryAfter * 1000), retryConfig.maxDelayMs);
|
||||
}
|
||||
|
||||
export type DiscordFetchOptions = {
|
||||
type DiscordFetchOptions = {
|
||||
retry?: RetryConfig;
|
||||
label?: string;
|
||||
};
|
||||
|
||||
@@ -160,7 +160,7 @@ function createDiscordApproverDmTargetResolver(configOverride?: DiscordExecAppro
|
||||
});
|
||||
}
|
||||
|
||||
export function createDiscordApprovalCapability(configOverride?: DiscordExecApprovalConfig | null) {
|
||||
function createDiscordApprovalCapability(configOverride?: DiscordExecApprovalConfig | null) {
|
||||
return createApproverRestrictedNativeApprovalCapability({
|
||||
channel: "discord",
|
||||
channelLabel: "Discord",
|
||||
|
||||
@@ -6,7 +6,7 @@ import type {
|
||||
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
||||
import { isRecord, normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime";
|
||||
|
||||
export type DiscordChannelPermissionsAuditEntry = {
|
||||
type DiscordChannelPermissionsAuditEntry = {
|
||||
channelId: string;
|
||||
ok: boolean;
|
||||
missing?: string[];
|
||||
@@ -35,7 +35,7 @@ function shouldAuditChannelConfig(config: DiscordGuildChannelConfig | undefined)
|
||||
return true;
|
||||
}
|
||||
|
||||
export function listConfiguredGuildChannelKeys(
|
||||
function listConfiguredGuildChannelKeys(
|
||||
guilds: Record<string, DiscordGuildEntry> | undefined,
|
||||
): string[] {
|
||||
if (!guilds) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { chunkMarkdownTextWithMode, type ChunkMode } from "openclaw/plugin-sdk/reply-chunking";
|
||||
|
||||
export type ChunkDiscordTextOpts = {
|
||||
type ChunkDiscordTextOpts = {
|
||||
/** Max characters per Discord message. Default: 2000. */
|
||||
maxChars?: number;
|
||||
/**
|
||||
|
||||
@@ -12,7 +12,7 @@ const DISCORD_STREAM_MAX_CHARS = 2000;
|
||||
const DEFAULT_THROTTLE_MS = 1200;
|
||||
const DISCORD_PREVIEW_ALLOWED_MENTIONS = { parse: [] };
|
||||
|
||||
export type DiscordDraftStream = {
|
||||
type DiscordDraftStream = {
|
||||
update: (text: string) => void;
|
||||
flush: () => Promise<void>;
|
||||
messageId: () => string | undefined;
|
||||
|
||||
@@ -51,7 +51,7 @@ export type DiscordInteractiveHandlerRegistration = PluginInteractiveRegistratio
|
||||
"discord"
|
||||
>;
|
||||
|
||||
export type DiscordInteractiveDispatchContext = Omit<
|
||||
type DiscordInteractiveDispatchContext = Omit<
|
||||
DiscordInteractiveHandlerContext,
|
||||
| "interaction"
|
||||
| "respond"
|
||||
|
||||
@@ -11,7 +11,7 @@ type DiscordSendRuntime = typeof import("./send.js");
|
||||
|
||||
export type DiscordSendFn = DiscordSendRuntime["sendMessageDiscord"];
|
||||
export type DiscordVoiceSendFn = DiscordSendRuntime["sendVoiceMessageDiscord"];
|
||||
export type DiscordFormattingOptions = {
|
||||
type DiscordFormattingOptions = {
|
||||
textLimit?: number;
|
||||
maxLinesPerMessage?: number;
|
||||
tableMode?: NonNullable<Parameters<DiscordSendFn>[2]>["tableMode"];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export type DiscordPreviewStreamMode = "off" | "partial" | "block";
|
||||
type DiscordPreviewStreamMode = "off" | "partial" | "block";
|
||||
|
||||
function parsePreviewStreamingMode(value: unknown): DiscordPreviewStreamMode | undefined {
|
||||
return value === "off" || value === "partial" || value === "block" ? value : undefined;
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime-env";
|
||||
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
|
||||
import type { ResolvedDiscordAccount } from "./accounts.js";
|
||||
|
||||
export function resolveDiscordProxyUrl(
|
||||
function resolveDiscordProxyUrl(
|
||||
account: Pick<ResolvedDiscordAccount, "config">,
|
||||
cfg: OpenClawConfig,
|
||||
): string | undefined {
|
||||
@@ -22,7 +22,7 @@ export function resolveDiscordProxyUrl(
|
||||
return trimmed || undefined;
|
||||
}
|
||||
|
||||
export function resolveDiscordProxyFetchByUrl(
|
||||
function resolveDiscordProxyFetchByUrl(
|
||||
proxyUrl: string | undefined,
|
||||
runtime?: Pick<RuntimeEnv, "error">,
|
||||
): typeof fetch | undefined {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { FormData as UndiciFormData } from "undici";
|
||||
import { RequestClient, type RequestClientOptions } from "./internal/discord.js";
|
||||
|
||||
export type ProxyRequestClientOptions = RequestClientOptions;
|
||||
type ProxyRequestClientOptions = RequestClientOptions;
|
||||
|
||||
export const DISCORD_REST_TIMEOUT_MS = 15_000;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
} from "openclaw/plugin-sdk/retry-runtime";
|
||||
import { RateLimitError } from "./internal/discord.js";
|
||||
|
||||
export const DISCORD_RETRY_DEFAULTS = {
|
||||
const DISCORD_RETRY_DEFAULTS = {
|
||||
attempts: 3,
|
||||
minDelayMs: 500,
|
||||
maxDelayMs: 30_000,
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
|
||||
export type SendDiscordTarget = DiscordTarget;
|
||||
|
||||
export type SendDiscordTargetParseOptions = DiscordTargetParseOptions;
|
||||
type SendDiscordTargetParseOptions = DiscordTargetParseOptions;
|
||||
|
||||
export const parseDiscordSendTarget = (
|
||||
raw: string,
|
||||
|
||||
@@ -150,7 +150,7 @@ export type DiscordChannelCreate = {
|
||||
nsfw?: boolean;
|
||||
};
|
||||
|
||||
export type DiscordForumTag = {
|
||||
type DiscordForumTag = {
|
||||
id?: string;
|
||||
name: string;
|
||||
moderated?: boolean;
|
||||
|
||||
@@ -10,7 +10,7 @@ import { mergeDiscordAccountConfig, resolveDiscordAccountConfig } from "./accoun
|
||||
import type { DiscordAccountConfig } from "./runtime-api.js";
|
||||
import { resolveDiscordToken } from "./token.js";
|
||||
|
||||
export type InspectedDiscordSetupAccount = {
|
||||
type InspectedDiscordSetupAccount = {
|
||||
accountId: string;
|
||||
enabled: boolean;
|
||||
token: string;
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
|
||||
const channel = "discord" as const;
|
||||
|
||||
export const DISCORD_TOKEN_HELP_LINES = [
|
||||
const DISCORD_TOKEN_HELP_LINES = [
|
||||
"1) Discord Developer Portal -> Applications -> New Application",
|
||||
"2) Bot -> Add Bot -> Reset Token -> copy token",
|
||||
"3) OAuth2 -> URL Generator -> scope 'bot' -> invite to your server",
|
||||
@@ -27,7 +27,7 @@ export const DISCORD_TOKEN_HELP_LINES = [
|
||||
`Docs: ${formatDocsLink("/discord", "discord")}`,
|
||||
];
|
||||
|
||||
export function setDiscordGuildChannelAllowlist(
|
||||
function setDiscordGuildChannelAllowlist(
|
||||
cfg: OpenClawConfig,
|
||||
accountId: string,
|
||||
entries: Array<{
|
||||
|
||||
@@ -31,7 +31,7 @@ import {
|
||||
import { discordSecurityAdapter } from "./security.js";
|
||||
import { deriveLegacySessionChatType } from "./session-contract.js";
|
||||
|
||||
export const DISCORD_CHANNEL = "discord" as const;
|
||||
const DISCORD_CHANNEL = "discord" as const;
|
||||
|
||||
type DiscordDoctorModule = typeof import("./doctor.js");
|
||||
type DiscordConfigAccessorAccount = {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/rout
|
||||
import { resolveAccountEntry } from "openclaw/plugin-sdk/routing";
|
||||
import { normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input";
|
||||
|
||||
export type DiscordTokenSource = "env" | "config" | "none";
|
||||
type DiscordTokenSource = "env" | "config" | "none";
|
||||
|
||||
export type DiscordTokenResolution = BaseTokenResolution & {
|
||||
source: DiscordTokenSource;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
|
||||
import { inspectDiscordAccount } from "./account-inspect.js";
|
||||
|
||||
export const DEFAULT_DISCORD_ACCENT_COLOR = "#5865F2";
|
||||
const DEFAULT_DISCORD_ACCENT_COLOR = "#5865F2";
|
||||
|
||||
type ResolveDiscordAccentColorParams = {
|
||||
cfg: OpenClawConfig;
|
||||
|
||||
@@ -2,8 +2,6 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
|
||||
import { Container } from "./internal/discord.js";
|
||||
import { normalizeDiscordAccentColor, resolveDiscordAccentColor } from "./ui-colors.js";
|
||||
|
||||
export { normalizeDiscordAccentColor, resolveDiscordAccentColor } from "./ui-colors.js";
|
||||
|
||||
type DiscordContainerComponents = ConstructorParameters<typeof Container>[0];
|
||||
|
||||
export class DiscordUiContainer extends Container {
|
||||
|
||||
Reference in New Issue
Block a user