Triangle.js Docs
    Preparing search index...

    Class Social

    Index

    Properties

    blocked: Blocked[]

    people you block

    Social config

    List of the client's friends

    notifications: Notification[]

    Notifications

    online: number

    The current number of people online

    List of "pending" relationships (shows in other tab on TETR.IO)

    defaultConfig: Types.Social.Config = ...

    Methods

    • Block a user

      Parameters

      • userID: string

      Returns Promise<false | undefined>

      false if the user is already blocked, true otherwise

      await client.social.block(await client.social.resolve('halp'));
      
    • Internal

      Returns void

    • Send a message to a specified user (based on id). Returns Promise<"you.fail" | "they.fail" | "you.ban" | "they.ban"> if suppressDMErrors is true and an error (social.dm.fail) is thrown.

      Parameters

      • userID: string
      • message: string

      Returns Promise<string | void | DM>

      await client.social.dm(await client.social.resolve('halp'), 'what\'s up?');
      
    • Send a user a friend request

      Parameters

      • userID: string

      Returns Promise<boolean>

      false if the user is already friended, true otherwise

      await client.social.friend(await client.social.resolve('halp'));
      

      If an error occurs (such as the user has blocked the client, etc)

    • Get a user + social data from the list of users and pending friends (OTHER tab in TETR.IO)

      Parameters

      • target: string

      Returns Classes.Relationship | null

      const user = await client.social.get('halp')
      
      const user = await client.social.get('646f633d276f42a80ba44304');
      
      const user = await client.social.get({ username: 'halp' });
      
      const user = await client.social.get({ id: '646f633d276f42a80ba44304 });
      
      // You can then use the object to read user data and interact with the user
      await user.dm('wanna play?');
      await user.invite();
    • Get a user + social data from the list of users and pending friends (OTHER tab in TETR.IO)

      Parameters

      • target: { id: string }

      Returns Classes.Relationship | null

      const user = await client.social.get('halp')
      
      const user = await client.social.get('646f633d276f42a80ba44304');
      
      const user = await client.social.get({ username: 'halp' });
      
      const user = await client.social.get({ id: '646f633d276f42a80ba44304 });
      
      // You can then use the object to read user data and interact with the user
      await user.dm('wanna play?');
      await user.invite();
    • Get a user + social data from the list of users and pending friends (OTHER tab in TETR.IO)

      Parameters

      • target: { username: string }

      Returns Classes.Relationship | null

      const user = await client.social.get('halp')
      
      const user = await client.social.get('646f633d276f42a80ba44304');
      
      const user = await client.social.get({ username: 'halp' });
      
      const user = await client.social.get({ id: '646f633d276f42a80ba44304 });
      
      // You can then use the object to read user data and interact with the user
      await user.dm('wanna play?');
      await user.invite();
    • Invite a user to your room. Note: the TETR.IO api doesn't send a response for a successful invite. Instead, Triangle.js waits 100 milliseconds for an error, and resolves/returns if there is no error.

      Parameters

      • userID: string

      Returns Promise<void>

      await client.social.invite(await client.social.resolve('halp'));
      
    • Marks all notifications as read

      Returns void

      client.social.markNotificationsAsRead();
      
    • Get the user id given a username

      Parameters

      • username: string

      Returns Promise<string>

    • Set the client's status

      Parameters

      Returns void

      client.social.status('online', 'lobby:X-QP');
      
    • Unblock a user. Note: unblocking a user will unfriend them if they are friended.

      Parameters

      • userID: string

      Returns Promise<void>

      false if the user is not unblocked, true otherwise

      await client.social.unblock(await client.social.resolve('halp'));
      
    • Unfriend a user. Note: unfriending a user will unblock them if they are blocked.

      Parameters

      • userID: string

      Returns Promise<boolean>

      false if the user is not unfriended, true otherwise

      await client.social.unfriend(await client.social.resolve('halp'));
      
    • Get a users' information based on their userid or username

      Parameters

      • id: string

      Returns Promise<Utils.APITypes.Users.User>

      const user = await client.social.who(await client.social.resolve('halp'));
      
    • Parameters

      • client: Client
      • config: Partial<Types.Social.Config>
      • initData: {
            notifications: Notification[];
            presences: {
                [userId: string]: {
                    detail: string;
                    invitable: boolean;
                    status: string;
                };
            };
            relationships: Types.Social.Relationship[];
            total_online: number;
        }

      Returns Classes.Social