SquadJS/squad-server/plugins/intervalled-broadcasts.js

40 lines
1003 B
JavaScript
Raw Normal View History

import BasePlugin from './base-plugin.js';
export default class IntervalledBroadcasts extends BasePlugin {
static get description() {
return (
'The <code>IntervalledBroadcasts</code> plugin allows you to set broadcasts, which will be broadcasted at ' +
'preset intervals'
);
}
static get defaultEnabled() {
return false;
}
static get optionsSpecification() {
return {
broadcasts: {
required: false,
description: 'Messages to broadcast.',
default: [],
example: ['This server is powered by SquadJS.']
},
interval: {
required: false,
description: 'Frequency of the broadcasts in milliseconds.',
default: 5 * 60 * 1000
}
};
}
constructor(server, options) {
2020-10-23 05:18:23 -05:00
super(server, options);
setInterval(async () => {
2020-10-23 05:18:23 -05:00
await server.rcon.broadcast(this.options.broadcasts[0]);
this.broadcasts.push(this.options.broadcasts.shift());
}, this.options.interval);
}
}