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 {
Id: number--

The friend's UserId

Username: string--

The friend's username

DisplayName: string--

The display name of the friend.

IsOnline: bool--

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(
userId: number,
limitMaxFriends: number?--

Optional max friends

) → Promise<{FriendData}>

Retrieves all friends.

promiseFriendPages​

FriendUtils.promiseFriendPages(userId: number) → Promise<FriendPages>

iterateFriendsYielding​

FriendUtils.iterateFriendsYielding(pages: FriendPages) → ()=>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": 44,
                "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": 53,
                "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": 68,
                "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": 89,
                "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": 115,
                "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": 144,
                "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": 174,
                "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": 197,
                "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": 26,
                "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": 6,
        "path": "src/friendutils/src/Shared/FriendUtils.lua"
    }
}