bedrock-portal 0.3.0 → 0.3.1
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/README.md +6 -0
- package/examples/portal.js +3 -0
- package/package.json +1 -1
- package/src/modules/autoFriendAdd.js +6 -3
package/README.md
CHANGED
|
@@ -64,6 +64,9 @@ Automatically adds the account's followers as friends and invites them to the ga
|
|
|
64
64
|
Options:
|
|
65
65
|
- **inviteOnAdd**: boolean - Automatically invites recently added friends to the game (default: false)
|
|
66
66
|
- **conditionToMeet**: (player: RawPlayer) => boolean - A function that returns a boolean. If the function returns true, followers will be added as a friend and the friends that don't will be removed (default: () => true)
|
|
67
|
+
- **checkInterval**: number - How often to check for friends to add/remove (default: 30000ms)
|
|
68
|
+
- **addInterval**: number - How long to wait between adding friends (default: 2000ms)
|
|
69
|
+
- **removeInterval**: number - How long to wait between removing friends (default: 2000ms)
|
|
67
70
|
|
|
68
71
|
```js
|
|
69
72
|
const { BedrockPortal, Modules } = require('bedrock-portal');
|
|
@@ -77,6 +80,9 @@ portal.use(Modules.autoFriendAdd);
|
|
|
77
80
|
portal.use(Modules.autoFriendAdd, {
|
|
78
81
|
inviteOnAdd: true,
|
|
79
82
|
conditionToMeet: (player) => player.presenceState === 'Online', // Only add friends that are online and remove friends that are offline
|
|
83
|
+
// checkInterval: 30000, // How often to check for friends to add/remove (optional - defaults to 30000ms)
|
|
84
|
+
// addInterval: 2000, // How long to wait between adding friends (optional - defaults to 2000ms)
|
|
85
|
+
// removeInterval: 2000, // How long to wait between removing friends (optional - defaults to 2000ms)
|
|
80
86
|
});
|
|
81
87
|
```
|
|
82
88
|
|
package/examples/portal.js
CHANGED
|
@@ -24,6 +24,9 @@ const main = async () => {
|
|
|
24
24
|
portal.use(Modules.autoFriendAdd, { // Automatically adds friends to the session
|
|
25
25
|
inviteOnAdd: true,
|
|
26
26
|
conditionToMeet: (player) => player.presenceState === 'Online', // Only add friends that are online and remove friends that are offline
|
|
27
|
+
// checkInterval: 30000, // How often to check for friends to add/remove (optional - defaults to 30000ms)
|
|
28
|
+
addInterval: 2000, // How long to wait between adding friends (optional - defaults to 2000ms)
|
|
29
|
+
removeInterval: 2000, // How long to wait between removing friends (optional - defaults to 2000ms)
|
|
27
30
|
});
|
|
28
31
|
|
|
29
32
|
// Put your event listeners before portal.start() to ensure you don't miss any events
|
package/package.json
CHANGED
|
@@ -8,6 +8,9 @@ class AutoFriendAdd extends Module {
|
|
|
8
8
|
this.options = {
|
|
9
9
|
inviteOnAdd: false,
|
|
10
10
|
conditionToMeet: () => true,
|
|
11
|
+
checkInterval: 30000,
|
|
12
|
+
addInterval: 2000,
|
|
13
|
+
removeInterval: 2000,
|
|
11
14
|
};
|
|
12
15
|
}
|
|
13
16
|
|
|
@@ -42,7 +45,7 @@ class AutoFriendAdd extends Module {
|
|
|
42
45
|
|
|
43
46
|
this.debug(`Added & invited ${account.gamertag}`);
|
|
44
47
|
|
|
45
|
-
await new Promise(resolve => setTimeout(resolve,
|
|
48
|
+
await new Promise(resolve => setTimeout(resolve, this.options.addInterval));
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
this.debug('Checking for friends to remove');
|
|
@@ -65,7 +68,7 @@ class AutoFriendAdd extends Module {
|
|
|
65
68
|
|
|
66
69
|
this.debug(`Removed ${account.gamertag}`);
|
|
67
70
|
|
|
68
|
-
await new Promise(resolve => setTimeout(resolve,
|
|
71
|
+
await new Promise(resolve => setTimeout(resolve, this.options.removeInterval));
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
}
|
|
@@ -73,7 +76,7 @@ class AutoFriendAdd extends Module {
|
|
|
73
76
|
this.debug(`Error: ${error.message}`, error);
|
|
74
77
|
}
|
|
75
78
|
|
|
76
|
-
await new Promise(resolve => setTimeout(resolve,
|
|
79
|
+
await new Promise(resolve => setTimeout(resolve, this.options.checkInterval));
|
|
77
80
|
}
|
|
78
81
|
}
|
|
79
82
|
}
|