Skip to main content

FriendUtils

Utlity functions to help find friends of a user. Also contains utility to make testing in studio easier.

Types

FriendData

interface FriendData {
Idnumber--

The friend's UserId

Usernamestring--

The friend's username

DisplayNamestring--

The display name of the friend.

IsOnlinebool--

If the friend is currently online

}

Functions

promiseAllStudioFriends

FriendUtils.promiseAllStudioFriends() → Promise<{FriendData}>

Returns the current studio users friends

FriendUtils.promiseAllStudioFriends()
	:Then(function(studioFriends)
		print(studioFriends)
	end)

onlineFriends

FriendUtils.onlineFriends(friends{FriendData}) → {FriendData}

Outputs a list of only online friends

friendsNotInGame

FriendUtils.friendsNotInGame(friends{FriendData}) → {FriendData}

Outputs a list of only friends not in game

promiseAllFriends

FriendUtils.promiseAllFriends(
userIdnumber,
limitMaxFriendsnumber?--

Optional max friends

) → Promise<{FriendData}>

Retrieves all friends.

promiseFriendPages

FriendUtils.promiseFriendPages(userIdnumber) → Promise<FriendPages>

iterateFriendsYielding

FriendUtils.iterateFriendsYielding(pagesFriendPages) → ()=>FrienData?--

Iterator

Iterates over the current FriendPage and returns the next page

promiseStudioServiceUserId

FriendUtils.promiseStudioServiceUserId() → Promise<number>

Gets the current studio user's user id.

tip

Consider using FriendUtils.promiseCurrentStudioUserId if you want this code to work while the game is running or in team create. This is specific to StudioService.

promiseCurrentStudioUserId

FriendUtils.promiseCurrentStudioUserId() → Promise<number>

Gets the current studio user's user id.

Show raw api
{
    "functions": [
        {
            "name": "promiseAllStudioFriends",
            "desc": "Returns the current studio users friends\n\n```lua\nFriendUtils.promiseAllStudioFriends()\n\t:Then(function(studioFriends)\n\t\tprint(studioFriends)\n\tend)\n```",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<{ FriendData }>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 34,
                "path": "src/friendutils/src/Shared/FriendUtils.lua"
            }
        },
        {
            "name": "onlineFriends",
            "desc": "Outputs a list of only online friends",
            "params": [
                {
                    "name": "friends",
                    "desc": "",
                    "lua_type": "{ FriendData }"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ FriendData }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 44,
                "path": "src/friendutils/src/Shared/FriendUtils.lua"
            }
        },
        {
            "name": "friendsNotInGame",
            "desc": "Outputs a list of only friends not in game",
            "params": [
                {
                    "name": "friends",
                    "desc": "",
                    "lua_type": "{ FriendData }"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ FriendData }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 59,
                "path": "src/friendutils/src/Shared/FriendUtils.lua"
            }
        },
        {
            "name": "promiseAllFriends",
            "desc": "Retrieves all friends.",
            "params": [
                {
                    "name": "userId",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "limitMaxFriends",
                    "desc": "Optional max friends",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<{ FriendData }>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 80,
                "path": "src/friendutils/src/Shared/FriendUtils.lua"
            }
        },
        {
            "name": "promiseFriendPages",
            "desc": "Wraps [Players.GetFriendsAsync]",
            "params": [
                {
                    "name": "userId",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<FriendPages>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 107,
                "path": "src/friendutils/src/Shared/FriendUtils.lua"
            }
        },
        {
            "name": "iterateFriendsYielding",
            "desc": "Iterates over the current FriendPage and returns the next page",
            "params": [
                {
                    "name": "pages",
                    "desc": "",
                    "lua_type": "FriendPages"
                }
            ],
            "returns": [
                {
                    "desc": "Iterator",
                    "lua_type": "() => FrienData?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 130,
                "path": "src/friendutils/src/Shared/FriendUtils.lua"
            }
        },
        {
            "name": "promiseStudioServiceUserId",
            "desc": "Gets the current studio user's user id.\n\n:::tip\nConsider using [FriendUtils.promiseCurrentStudioUserId] if you want this code\nto work while the game is running or in team create. This is specific to [StudioService].\n:::",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<number>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 160,
                "path": "src/friendutils/src/Shared/FriendUtils.lua"
            }
        },
        {
            "name": "promiseCurrentStudioUserId",
            "desc": "Gets the current studio user's user id.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<number>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 183,
                "path": "src/friendutils/src/Shared/FriendUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "FriendData",
            "desc": "",
            "fields": [
                {
                    "name": "Id",
                    "lua_type": "number",
                    "desc": "The friend's UserId"
                },
                {
                    "name": "Username",
                    "lua_type": "string",
                    "desc": "The friend's username"
                },
                {
                    "name": "DisplayName",
                    "lua_type": "string",
                    "desc": "The display name of the friend."
                },
                {
                    "name": "IsOnline",
                    "lua_type": "bool",
                    "desc": "If the friend is currently online"
                }
            ],
            "source": {
                "line": 22,
                "path": "src/friendutils/src/Shared/FriendUtils.lua"
            }
        }
    ],
    "name": "FriendUtils",
    "desc": "Utlity functions to help find friends of a user. Also contains utility to make testing in studio easier.",
    "source": {
        "line": 5,
        "path": "src/friendutils/src/Shared/FriendUtils.lua"
    }
}