Returns a promise that resolves when any of the specified events occur.
A promise that resolves with a tuple of the event name and arguments
try {
const [event, ...args] = await events.waitForAnyEvent(
['player_join', 'player_leave'],
(event, ...args) => event === 'player_join' || args[0] === 'admin',
10000
);
if (event === 'player_join') {
console.log(`Player ${args[0]} joined`);
} else {
console.log(`Player ${args[0]} left`);
}
} catch (error) {
console.log('Timed out waiting for player events');
}
Waits for any of the specified operating system events to occur
⚠️ NOTE: Requires an active event loop to process events
See