mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 20:28:29 +00:00
chore: Enable more lint rules, disable some that trigger a lot. Will clean up later.
This commit is contained in:
@@ -21,7 +21,7 @@ function listConfiguredAccountIds(cfg: OpenClawConfig): string[] {
|
||||
export function listDiscordAccountIds(cfg: OpenClawConfig): string[] {
|
||||
const ids = listConfiguredAccountIds(cfg);
|
||||
if (ids.length === 0) return [DEFAULT_ACCOUNT_ID];
|
||||
return ids.sort((a, b) => a.localeCompare(b));
|
||||
return ids.toSorted((a, b) => a.localeCompare(b));
|
||||
}
|
||||
|
||||
export function resolveDefaultDiscordAccountId(cfg: OpenClawConfig): string {
|
||||
|
||||
@@ -49,7 +49,7 @@ function listConfiguredGuildChannelKeys(
|
||||
ids.add(channelId);
|
||||
}
|
||||
}
|
||||
return [...ids].sort((a, b) => a.localeCompare(b));
|
||||
return [...ids].toSorted((a, b) => a.localeCompare(b));
|
||||
}
|
||||
|
||||
export function collectDiscordAuditChannelIds(params: {
|
||||
|
||||
@@ -17,9 +17,7 @@ vi.mock("@buape/carbon", () => ({
|
||||
MessageReactionAddListener: class {},
|
||||
MessageReactionRemoveListener: class {},
|
||||
PresenceUpdateListener: class {},
|
||||
Row: class {
|
||||
constructor(_components: unknown[]) {}
|
||||
},
|
||||
Row: class {},
|
||||
}));
|
||||
|
||||
vi.mock("../auto-reply/dispatch.js", async (importOriginal) => {
|
||||
|
||||
@@ -154,7 +154,7 @@ export function resolveDiscordCommandAuthorized(params: {
|
||||
}
|
||||
|
||||
export function resolveDiscordGuildEntry(params: {
|
||||
guild?: Guild<true> | Guild<false> | null;
|
||||
guild?: Guild<true> | Guild | null;
|
||||
guildEntries?: Record<string, DiscordGuildEntryResolved>;
|
||||
}): DiscordGuildEntryResolved | null {
|
||||
const guild = params.guild;
|
||||
|
||||
@@ -77,11 +77,7 @@ async function listGuildChannels(
|
||||
fetcher: typeof fetch,
|
||||
guildId: string,
|
||||
): Promise<DiscordChannelSummary[]> {
|
||||
const raw = (await fetchDiscord(
|
||||
`/guilds/${guildId}/channels`,
|
||||
token,
|
||||
fetcher,
|
||||
)) as RESTGetAPIGuildChannelsResult;
|
||||
const raw = await fetchDiscord(`/guilds/${guildId}/channels`, token, fetcher);
|
||||
return raw
|
||||
.filter((channel) => Boolean(channel.id) && "name" in channel)
|
||||
.map((channel) => {
|
||||
@@ -105,11 +101,7 @@ async function fetchChannel(
|
||||
fetcher: typeof fetch,
|
||||
channelId: string,
|
||||
): Promise<DiscordChannelSummary | null> {
|
||||
const raw = (await fetchDiscord(
|
||||
`/channels/${channelId}`,
|
||||
token,
|
||||
fetcher,
|
||||
)) as RESTGetAPIChannelResult;
|
||||
const raw = await fetchDiscord(`/channels/${channelId}`, token, fetcher);
|
||||
if (!raw || !("guild_id" in raw)) return null;
|
||||
return {
|
||||
id: raw.id,
|
||||
|
||||
@@ -10,7 +10,7 @@ import { normalizeDiscordToken } from "./token.js";
|
||||
|
||||
const PERMISSION_ENTRIES = Object.entries(PermissionFlagsBits).filter(
|
||||
([, value]) => typeof value === "bigint",
|
||||
) as Array<[string, bigint]>;
|
||||
);
|
||||
|
||||
type DiscordClientOpts = {
|
||||
token?: string;
|
||||
@@ -60,7 +60,7 @@ function removePermissionBits(base: bigint, deny?: string) {
|
||||
function bitfieldToPermissions(bitfield: bigint) {
|
||||
return PERMISSION_ENTRIES.filter(([, value]) => (bitfield & value) === value)
|
||||
.map(([name]) => name)
|
||||
.sort();
|
||||
.toSorted();
|
||||
}
|
||||
|
||||
export function isThreadChannelType(channelType?: number) {
|
||||
|
||||
Reference in New Issue
Block a user