-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathshutdown.js
More file actions
29 lines (25 loc) · 948 Bytes
/
shutdown.js
File metadata and controls
29 lines (25 loc) · 948 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict';
const { Broadcast, PlayerRoles } = require('ranvier');
/**
* Shut down the MUD from within the game.
*/
module.exports = {
requiredRole: PlayerRoles.ADMIN,
command: state => async (time, player) => {
if (time === 'now') {
Broadcast.sayAt(state.PlayerManager, '<b><yellow>Game is shutting down now!</yellow></b>');
await state.PlayerManager.saveAll();
process.exit();
return;
}
if (!time.length || time !== 'sure') {
return Broadcast.sayAt(player, 'You must confirm the shutdown with "shutdown sure" or force immediate shutdown with "shutdown now"');
}
Broadcast.sayAt(state.PlayerManager, `<b><yellow>Game will shut down in ${30} seconds.</yellow></b>`);
setTimeout(async _ => {
Broadcast.sayAt(state.PlayerManager, '<b><yellow>Game is shutting down now!</yellow></b>');
await state.PlayerManager.saveAll();
await process.exit();
}, 30000);
}
};