@donation-alerts/common
Version:
Common utils and types that are used in other @donation-alerts packages.
53 lines • 1.42 kB
TypeScript
/**
* A type that represents a user and contains a user ID.
*/
export interface UserIdResolvableType {
/**
* The ID of the user.
*/
id: number | string;
}
/**
* A type that represents a user and contains a username.
*/
export interface UserNameResolvableType {
/**
* The name of the user.
*/
name: string;
}
/**
* A user ID or an object containing `id` field with user ID.
*
* @example
* let userId: UserIdResolvable
*
* userId = 123456789;
* userId = '123456789';
* userId = { id: 123456789 };
* userId = { id: '123456789' };
*/
export type UserIdResolvable = string | number | UserIdResolvableType;
/**
* A username or an object containing `name` field with username.
*
* @example
* let username: UserNameResolvable
*
* username = 'stimulcross';
* username = { name: 'stimulcross' };
*/
export type UserNameResolvable = string | UserNameResolvableType;
/**
* Extracts the user ID from an argument that is possibly an object containing that ID.
*
* @param user The user ID or object.
*/
export declare function extractUserId(user: UserIdResolvable): number;
/**
* Extracts the username from an argument that is possibly an object containing that name.
*
* @param user The username or object containing `name` field with username.
*/
export declare function extractUserName(user: UserNameResolvable): string;
//# sourceMappingURL=user-resovlers.d.ts.map