Files
openclaw/extensions/discord/src/internal/api.users.ts
2026-04-29 14:22:58 +01:00

20 lines
669 B
TypeScript

import { Routes, type APIChannel, type APIUser } from "discord-api-types/v10";
import type { RequestClient } from "./rest.js";
export async function getCurrentUser(rest: RequestClient): Promise<APIUser> {
return (await rest.get(Routes.user("@me"))) as APIUser;
}
export async function getUser(rest: RequestClient, userId: string): Promise<APIUser> {
return (await rest.get(Routes.user(userId))) as APIUser;
}
export async function createUserDmChannel(
rest: RequestClient,
recipientId: string,
): Promise<Pick<APIChannel, "id">> {
return (await rest.post(Routes.userChannels(), {
body: { recipient_id: recipientId },
})) as Pick<APIChannel, "id">;
}