UNPKG

@haelp/teto

Version:

A typescript-based controllable TETR.IO client.

108 lines (107 loc) 3.96 kB
import { Events, Social as SocialTypes } from "../../types"; import { APITypes } from "../../utils"; import type { Client } from "../client"; import { Relationship } from "./relationship"; export declare class Social { private client; /** The current number of people online */ online: number; /** List of the client's friends */ friends: Relationship[]; /** List of "pending" relationships (shows in `other` tab on TETR.IO) */ other: Relationship[]; /** people you block */ blocked: SocialTypes.Blocked[]; /** Notifications */ notifications: SocialTypes.Notification[]; /** @hideconstructor */ private constructor(); static create(client: Client, initData: Events.in.Client["client.ready"]["social"]): Promise<Social>; private get api(); private init; /** * Marks all notifications as read * @example * client.social.markNotificationsAsRead(); */ markNotificationsAsRead(): void; /** * Get a user + social data from the list of users and pending friends (OTHER tab in TETR.IO) * @example * const user = await client.social.get('halp') * @example * const user = await client.social.get('646f633d276f42a80ba44304'); * @example * const user = await client.social.get({ username: 'halp' }); * @example * const user = await client.social.get({ id: '646f633d276f42a80ba44304 }); * @example * // You can then use the object to read user data and interact with the user * await user.dm('wanna play?'); * await user.invite(); */ get(target: string): Relationship | null; get(target: { id: string; }): Relationship | null; get(target: { username: string; }): Relationship | null; /** * Get the user id given a username */ resolve(username: string): Promise<string>; /** Get a users' information based on their userid or username * @example * const user = await client.social.who(await client.social.resolve('halp')); */ who(id: string): Promise<APITypes.Users.User>; /** * Send a message to a specified user (based on id) * @example * await client.social.dm(await client.social.resolve('halp'), 'what\'s up?'); */ dm(userID: string, message: string): Promise<SocialTypes.DM>; /** * Send a user a friend request * @example * await client.social.friend(await client.social.resolve('halp')); * @returns false if the user is already friended, true otherwise * @throws {Error} If an error occurs (such as the user has blocked the client, etc) */ friend(userID: string): Promise<boolean>; /** * Unfriend a user. Note: unfriending a user will unblock them if they are blocked. * @example * await client.social.unfriend(await client.social.resolve('halp')); * @returns false if the user is not unfriended, true otherwise */ unfriend(userID: string): Promise<boolean>; /** * Block a user * @example * await client.social.block(await client.social.resolve('halp')); * @returns false if the user is already blocked, true otherwise */ block(userID: string): Promise<false | undefined>; /** * Unblock a user. Note: unblocking a user will unfriend them if they are friended. * @example * await client.social.unblock(await client.social.resolve('halp')); * @returns false if the user is not unblocked, true otherwise */ unblock(userID: string): Promise<void>; /** * Invite a user to your room * @example * await client.social.invite(await client.social.resolve('halp')); */ invite(userID: string): Promise<void>; /** * Set the client's status * @example * client.social.status('online', 'lobby:X-QP'); */ status(status: SocialTypes.Status, detail?: SocialTypes.Detail | String): void; } export * from "./relationship";