mirror of
https://github.com/AsgardEternal/SquadJS.git
synced 2024-09-28 19:54:25 -05:00
40 lines
1.0 KiB
JavaScript
40 lines
1.0 KiB
JavaScript
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, optionsRaw) {
|
|
super(server, options, optionsRaw);
|
|
|
|
setInterval(async () => {
|
|
await this.server.rcon.broadcast(this.options.broadcasts[0]);
|
|
this.broadcasts.push(this.options.broadcasts.shift());
|
|
}, this.options.interval);
|
|
}
|
|
}
|