SquadJS/plugins/intervalled-broadcasts/index.js

28 lines
718 B
JavaScript
Raw Normal View History

export default {
name: 'intervalled-broadcasts',
description:
'The `intervalled-broadcasts` plugin allows you to set broadcasts, which will be broadcasted at preset intervals',
defaultEnabled: false,
optionsSpec: {
broadcasts: {
required: false,
2020-09-12 13:00:25 -05:00
description: 'The broadcasted messages.',
default: ['Server powered by SquadJS.']
},
interval: {
required: false,
2020-09-12 13:00:25 -05:00
description: 'How frequently to broadcast in seconds.',
default: 5 * 60 * 1000
}
},
init: async (server, options) => {
setInterval(() => {
server.rcon.broadcast(options.broadcasts[0]);
options.broadcasts.push(options.broadcasts.shift());
}, options.interval);
}
};