@quenty/friendutils 3.3.0 → 3.4.0-canary.241.a4e8214.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +6 -24
- package/package.json +4 -4
- package/src/Shared/FriendUtils.lua +64 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.4.0-canary.241.a4e8214.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/friendutils@3.3.1...@quenty/friendutils@3.4.0-canary.241.a4e8214.0) (2022-01-03)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/friendutils
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [3.3.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/friendutils@3.3.0...@quenty/friendutils@3.3.1) (2021-12-30)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @quenty/friendutils
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [3.3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/friendutils@3.2.0...@quenty/friendutils@3.3.0) (2021-12-18)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @quenty/friendutils
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
## FriendUtils
|
|
2
2
|
<div align="center">
|
|
3
|
-
<a href="http://quenty.github.io/
|
|
4
|
-
<img src="https://
|
|
3
|
+
<a href="http://quenty.github.io/NevermoreEngine/">
|
|
4
|
+
<img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/docs.yml/badge.svg" alt="Documentation status" />
|
|
5
5
|
</a>
|
|
6
6
|
<a href="https://discord.gg/mhtGUS8">
|
|
7
|
-
<img src="https://img.shields.io/
|
|
7
|
+
<img src="https://img.shields.io/discord/385151591524597761?color=5865F2&label=discord&logo=discord&logoColor=white" alt="Discord" />
|
|
8
8
|
</a>
|
|
9
9
|
<a href="https://github.com/Quenty/NevermoreEngine/actions">
|
|
10
10
|
<img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/build.yml/badge.svg" alt="Build and release status" />
|
|
@@ -13,27 +13,9 @@
|
|
|
13
13
|
|
|
14
14
|
Utlity functions to help find friends of a user. Also contains utility to make testing in studio easier.
|
|
15
15
|
|
|
16
|
+
<div align="center"><a href="https://quenty.github.io/NevermoreEngine/api/FriendUtils">View docs →</a></div>
|
|
17
|
+
|
|
16
18
|
## Installation
|
|
17
19
|
```
|
|
18
20
|
npm install @quenty/friendutils --save
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Usage
|
|
22
|
-
Usage is designed to be simple.
|
|
23
|
-
|
|
24
|
-
### `FriendUtils.promiseAllStudioFriends()`
|
|
25
|
-
|
|
26
|
-
### `FriendUtils.onlineFriends(friends)`
|
|
27
|
-
|
|
28
|
-
### `FriendUtils.friendsNotInGame(friends)`
|
|
29
|
-
|
|
30
|
-
### `FriendUtils.promiseAllFriends(userId, limitMaxFriends)`
|
|
31
|
-
|
|
32
|
-
### `FriendUtils.promiseFriendPages(userId)`
|
|
33
|
-
|
|
34
|
-
### `FriendUtils.iterateFriendsYielding(pages)`
|
|
35
|
-
|
|
36
|
-
### `FriendUtils.promiseStudioServiceUserId()`
|
|
37
|
-
|
|
38
|
-
### `FriendUtils.promiseCurrentStudioUserId()`
|
|
39
|
-
|
|
21
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/friendutils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0-canary.241.a4e8214.0",
|
|
4
4
|
"description": "Utlity functions to help find friends of a user. Also contains utility to make testing in studio easier.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/loader": "
|
|
29
|
-
"@quenty/promise": "
|
|
28
|
+
"@quenty/loader": "3.2.0-canary.241.a4e8214.0",
|
|
29
|
+
"@quenty/promise": "3.4.0-canary.241.a4e8214.0"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "a4e821471f35998d63f38a4f4a578e07b4e79035"
|
|
35
35
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
--[=[
|
|
2
|
+
Utlity functions to help find friends of a user. Also contains utility to make testing in studio easier.
|
|
3
|
+
@class FriendUtils
|
|
4
|
+
]=]
|
|
3
5
|
|
|
4
6
|
local require = require(script.Parent.loader).load(script)
|
|
5
7
|
|
|
@@ -9,11 +11,36 @@ local Promise = require("Promise")
|
|
|
9
11
|
|
|
10
12
|
local FriendUtils = {}
|
|
11
13
|
|
|
14
|
+
--[=[
|
|
15
|
+
@interface FriendData
|
|
16
|
+
.Id number -- The friend's UserId
|
|
17
|
+
.Username string -- The friend's username
|
|
18
|
+
.DisplayName string -- The display name of the friend.
|
|
19
|
+
.IsOnline bool -- If the friend is currently online
|
|
20
|
+
@within FriendUtils
|
|
21
|
+
]=]
|
|
22
|
+
|
|
23
|
+
--[=[
|
|
24
|
+
Returns the current studio users friends
|
|
25
|
+
|
|
26
|
+
```lua
|
|
27
|
+
FriendUtils.promiseAllStudioFriends()
|
|
28
|
+
:Then(function(studioFriends)
|
|
29
|
+
print(studioFriends)
|
|
30
|
+
end)
|
|
31
|
+
```
|
|
32
|
+
@return Promise<{ FriendData }>
|
|
33
|
+
]=]
|
|
12
34
|
function FriendUtils.promiseAllStudioFriends()
|
|
13
35
|
return FriendUtils.promiseCurrentStudioUserId()
|
|
14
36
|
:Then(FriendUtils.promiseAllFriends)
|
|
15
37
|
end
|
|
16
38
|
|
|
39
|
+
--[=[
|
|
40
|
+
Outputs a list of only online friends
|
|
41
|
+
@param friends { FriendData }
|
|
42
|
+
@return { FriendData }
|
|
43
|
+
]=]
|
|
17
44
|
function FriendUtils.onlineFriends(friends)
|
|
18
45
|
local onlineFriends = {}
|
|
19
46
|
for _, friend in pairs(friends) do
|
|
@@ -24,6 +51,11 @@ function FriendUtils.onlineFriends(friends)
|
|
|
24
51
|
return onlineFriends
|
|
25
52
|
end
|
|
26
53
|
|
|
54
|
+
--[=[
|
|
55
|
+
Outputs a list of only friends not in game
|
|
56
|
+
@param friends { FriendData }
|
|
57
|
+
@return { FriendData }
|
|
58
|
+
]=]
|
|
27
59
|
function FriendUtils.friendsNotInGame(friends)
|
|
28
60
|
local userIdsInGame = {}
|
|
29
61
|
for _, player in pairs(Players:GetPlayers()) do
|
|
@@ -39,7 +71,12 @@ function FriendUtils.friendsNotInGame(friends)
|
|
|
39
71
|
return onlineFriends
|
|
40
72
|
end
|
|
41
73
|
|
|
42
|
-
--
|
|
74
|
+
--[=[
|
|
75
|
+
Retrieves all friends.
|
|
76
|
+
@param userId number
|
|
77
|
+
@param limitMaxFriends number? -- Optional max friends
|
|
78
|
+
@return Promise<{ FriendData }>
|
|
79
|
+
]=]
|
|
43
80
|
function FriendUtils.promiseAllFriends(userId, limitMaxFriends)
|
|
44
81
|
assert(userId, "Bad userId")
|
|
45
82
|
|
|
@@ -62,6 +99,11 @@ function FriendUtils.promiseAllFriends(userId, limitMaxFriends)
|
|
|
62
99
|
end)
|
|
63
100
|
end
|
|
64
101
|
|
|
102
|
+
--[=[
|
|
103
|
+
Wraps [Players.GetFriendsAsync]
|
|
104
|
+
@param userId number
|
|
105
|
+
@return Promise<FriendPages>
|
|
106
|
+
]=]
|
|
65
107
|
function FriendUtils.promiseFriendPages(userId)
|
|
66
108
|
assert(type(userId) == "number", "Bad userId")
|
|
67
109
|
|
|
@@ -80,6 +122,11 @@ function FriendUtils.promiseFriendPages(userId)
|
|
|
80
122
|
end)
|
|
81
123
|
end
|
|
82
124
|
|
|
125
|
+
--[=[
|
|
126
|
+
Iterates over the current FriendPage and returns the next page
|
|
127
|
+
@param pages FriendPages
|
|
128
|
+
@return () => FrienData? -- Iterator
|
|
129
|
+
]=]
|
|
83
130
|
function FriendUtils.iterateFriendsYielding(pages)
|
|
84
131
|
assert(pages, "Bad pages")
|
|
85
132
|
|
|
@@ -100,6 +147,16 @@ function FriendUtils.iterateFriendsYielding(pages)
|
|
|
100
147
|
end)
|
|
101
148
|
end
|
|
102
149
|
|
|
150
|
+
--[=[
|
|
151
|
+
Gets the current studio user's user id.
|
|
152
|
+
|
|
153
|
+
:::tip
|
|
154
|
+
Consider using [FriendUtils.promiseCurrentStudioUserId] if you want this code
|
|
155
|
+
to work while the game is running or in team create. This is specific to [StudioService].
|
|
156
|
+
:::
|
|
157
|
+
|
|
158
|
+
@return Promise<number>
|
|
159
|
+
]=]
|
|
103
160
|
function FriendUtils.promiseStudioServiceUserId()
|
|
104
161
|
return Promise.new(function(resolve, reject)
|
|
105
162
|
local userId
|
|
@@ -119,6 +176,10 @@ function FriendUtils.promiseStudioServiceUserId()
|
|
|
119
176
|
end)
|
|
120
177
|
end
|
|
121
178
|
|
|
179
|
+
--[=[
|
|
180
|
+
Gets the current studio user's user id.
|
|
181
|
+
@return Promise<number>
|
|
182
|
+
]=]
|
|
122
183
|
function FriendUtils.promiseCurrentStudioUserId()
|
|
123
184
|
return FriendUtils.promiseStudioServiceUserId()
|
|
124
185
|
:Catch(function(...)
|