oceanic.js
Version:
A NodeJS library for interfacing with Discord.
87 lines (86 loc) • 3.87 kB
TypeScript
/** @module User */
import Base from "./Base";
import type PrivateChannel from "./PrivateChannel";
import type Entitlement from "./Entitlement";
import type TestEntitlement from "./TestEntitlement";
import Clan from "./Clan";
import { type ImageFormat } from "../Constants";
import type Client from "../Client";
import type { AvatarDecorationData, Collectibles, RawUser } from "../types/users";
import type { JSONUser } from "../types/json";
import type { SearchEntitlementsOptions } from "../types/applications";
/** Represents a user. */
export default class User extends Base {
/** The user's banner color. If this member was received via the gateway, this will never be present. */
accentColor?: number | null;
/** The user's avatar hash. */
avatar: string | null;
/** The data for this user's avatar decoration. */
avatarDecorationData: AvatarDecorationData | null;
/** The user's banner hash. If this member was received via the gateway, this will never be present. */
banner?: string | null;
/** If this user is a bot. */
bot: boolean;
/** The primary clan this user is in. */
clan: Clan | null;
/** The user's collectibles. */
collectibles: Collectibles | null;
/** The 4 digits after this user's username, if they have not been migrated. If migrated, this will be a single "0". */
discriminator: string;
/** The user's display name, if set. */
globalName: string | null;
/** The user's public [flags](https://discord.com/developers/docs/resources/user#user-object-user-flags). */
publicFlags: number;
/** If this user is an official discord system user. */
system: boolean;
/** The user's username. */
username: string;
constructor(data: RawUser, client: Client);
protected update(data: Partial<RawUser>): void;
/** The default avatar value of this user. */
get defaultAvatar(): number;
/** If this user has migrated to the new username system. */
get isMigrated(): boolean;
/** A string that will mention this user. */
get mention(): string;
/** This user's unique username, if migrated, else a combination of the user's username and discriminator. */
get tag(): string;
/**
* The url of this user's avatar decoration. This will always be a png.
* Discord does not combine the decoration and their current avatar for you. This is ONLY the decoration.
* @param size The dimensions of the image.
*/
avatarDecorationURL(size?: number): string | null;
/**
* The url of this user's avatar (or default avatar, if they have not set an avatar).
* @param format The format the url should be.
* @param size The dimensions of the image.
*/
avatarURL(format?: ImageFormat, size?: number): string;
/**
* The url of this user's banner.
* @param format The format the url should be.
* @param size The dimensions of the image.
*/
bannerURL(format?: ImageFormat, size?: number): string | null;
/**
* Create a direct message with this user.
*/
createDM(): Promise<PrivateChannel>;
/**
* Create a test entitlement for this user.
* @param skuID The ID of the SKU to create an entitlement for.
* @param applicationID The ID of the application to create the entitlement for. If present, defaults to the logged in client's application id.
*/
createTestEntitlement(skuID: string, applicationID?: string): Promise<TestEntitlement>;
/**
* The url of this user's default avatar.
*/
defaultAvatarURL(): string;
/**
* Get the entitlements for this guild.
* @param options The options for getting the entitlements.
*/
getEntitlements(options?: Omit<SearchEntitlementsOptions, "userID">, applicationID?: string): Promise<Array<Entitlement | TestEntitlement>>;
toJSON(): JSONUser;
}