mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 17:38:27 +00:00
style: format
This commit is contained in:
@@ -27,11 +27,16 @@ describe("discord audit", () => {
|
||||
},
|
||||
} as unknown as import("../config/config.js").ClawdbotConfig;
|
||||
|
||||
const collected = collectDiscordAuditChannelIds({ cfg, accountId: "default" });
|
||||
const collected = collectDiscordAuditChannelIds({
|
||||
cfg,
|
||||
accountId: "default",
|
||||
});
|
||||
expect(collected.channelIds).toEqual(["111"]);
|
||||
expect(collected.unresolvedChannels).toBe(1);
|
||||
|
||||
(fetchChannelPermissionsDiscord as unknown as ReturnType<typeof vi.fn>).mockResolvedValueOnce({
|
||||
(
|
||||
fetchChannelPermissionsDiscord as unknown as ReturnType<typeof vi.fn>
|
||||
).mockResolvedValueOnce({
|
||||
channelId: "111",
|
||||
permissions: ["ViewChannel"],
|
||||
raw: "0",
|
||||
@@ -49,4 +54,3 @@ describe("discord audit", () => {
|
||||
expect(audit.channels[0]?.missing).toContain("SendMessages");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -27,7 +27,9 @@ function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
||||
}
|
||||
|
||||
function shouldAuditChannelConfig(config: DiscordGuildChannelConfig | undefined) {
|
||||
function shouldAuditChannelConfig(
|
||||
config: DiscordGuildChannelConfig | undefined,
|
||||
) {
|
||||
if (!config) return true;
|
||||
if (config.allow === false) return false;
|
||||
if (config.enabled === false) return false;
|
||||
@@ -46,7 +48,11 @@ function listConfiguredGuildChannelKeys(
|
||||
for (const [key, value] of Object.entries(channelsRaw)) {
|
||||
const channelId = String(key).trim();
|
||||
if (!channelId) continue;
|
||||
if (!shouldAuditChannelConfig(value as DiscordGuildChannelConfig | undefined))
|
||||
if (
|
||||
!shouldAuditChannelConfig(
|
||||
value as DiscordGuildChannelConfig | undefined,
|
||||
)
|
||||
)
|
||||
continue;
|
||||
ids.add(channelId);
|
||||
}
|
||||
@@ -119,4 +125,3 @@ export async function auditDiscordChannelPermissions(params: {
|
||||
elapsedMs: Date.now() - started,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
} from "discord-api-types/v10";
|
||||
|
||||
import { loadConfig } from "../config/config.js";
|
||||
import { recordProviderActivity } from "../infra/provider-activity.js";
|
||||
import type { RetryConfig } from "../infra/retry.js";
|
||||
import {
|
||||
createDiscordRetryRunner,
|
||||
@@ -32,7 +33,6 @@ import { loadWebMedia, loadWebMediaRaw } from "../web/media.js";
|
||||
import { resolveDiscordAccount } from "./accounts.js";
|
||||
import { chunkDiscordText } from "./chunk.js";
|
||||
import { normalizeDiscordToken } from "./token.js";
|
||||
import { recordProviderActivity } from "../infra/provider-activity.js";
|
||||
|
||||
const DISCORD_TEXT_LIMIT = 2000;
|
||||
const DISCORD_MAX_STICKERS = 3;
|
||||
|
||||
Reference in New Issue
Block a user