Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Java/Openclaw/extensions/discord/src/   (KI Agentensystem Version 22©)  Datei vom 26.3.2026 mit Größe 2 kB image not shown  

Quelle  directory-config.ts

  Sprache: JAVA
 

Spracherkennung für: .ts vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
import {
  createResolvedDirectoryEntriesLister,
  type DirectoryConfigParams,
} from "openclaw/plugin-sdk/directory-config-runtime";
import { mergeDiscordAccountConfig, resolveDefaultDiscordAccountId } from "./accounts.js";

function resolveDiscordDirectoryConfigAccount(
  cfg: DirectoryConfigParams["cfg"],
  accountId?: string | null,
) {
  const resolvedAccountId = normalizeAccountId(accountId ?? resolveDefaultDiscordAccountId(cfg));
  const config = mergeDiscordAccountConfig(cfg, resolvedAccountId);
  return {
    accountId: resolvedAccountId,
    config,
    dm: config.dm,
  };
}

export const listDiscordDirectoryPeersFromConfig = createResolvedDirectoryEntriesLister<
  ReturnType<typeof resolveDiscordDirectoryConfigAccount>
>({
  kind: "user",
  resolveAccount: (cfg, accountId) => resolveDiscordDirectoryConfigAccount(cfg, accountId),
  resolveSources: (account) => {
    const allowFrom = account.config.allowFrom ?? account.config.dm?.allowFrom ?? [];
    const guildUsers = Object.values(account.config.guilds ?? {}).flatMap((guild) =>
      (guild.users ?? []).concat(
        Object.values(guild.channels ?? {}).flatMap((channel) => channel.users ?? []),
      ),
    );
    return [allowFrom, Object.keys(account.config.dms ?? {}), guildUsers];
  },
  normalizeId: (raw) => {
    const mention = raw.match(/^<@!?(\d+)>$/);
    const cleaned = (mention?.[1] ?? raw).replace(/^(discord|user):/i, "").trim();
    return /^\d+$/.test(cleaned) ? `user:${cleaned}` : null;
  },
});

export const listDiscordDirectoryGroupsFromConfig = createResolvedDirectoryEntriesLister<
  ReturnType<typeof resolveDiscordDirectoryConfigAccount>
>({
  kind: "group",
  resolveAccount: (cfg, accountId) => resolveDiscordDirectoryConfigAccount(cfg, accountId),
  resolveSources: (account) =>
    Object.values(account.config.guilds ?? {}).map((guild) => Object.keys(guild.channels ?? {})),
  normalizeId: (raw) => {
    const mention = raw.match(/^<#(\d+)>$/);
    const cleaned = (mention?.[1] ?? raw).replace(/^(discord|channel|group):/i, "").trim();
    return /^\d+$/.test(cleaned) ? `channel:${cleaned}` : null;
  },
});

¤ Dauer der Verarbeitung: 0.32 Sekunden  (vorverarbeitet am  2026-04-27) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.