SquadJS/plugins/intervalled-broadcasts/index.js
2020-09-12 11:44:11 +02:00

30 lines
767 B
JavaScript

export default {
name: 'intervalled-broadcasts',
description:
'The `intervalled-broadcasts` plugin allows you to set broadcasts, which will be broadcasted at certain intervals',
defaultEnabled: false,
optionsSpec: {
broadcasts: {
type: 'Array',
required: false,
default: ['Server powered by SquadJS.'],
description: 'The broadcasted messages.'
},
interval: {
type: 'Number',
required: false,
default: 150 * 1000,
description: 'How frequently to broadcast in seconds.'
}
},
init: async (server, options) => {
setInterval(() => {
server.rcon.broadcast(options.broadcasts[0]);
options.broadcasts.push(options.broadcasts.shift());
}, options.interval.default);
}
};