SquadJS/squad-server/plugins/discord-round-winner.js

49 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-10-21 14:28:29 -05:00
import DiscordBasePlugin from './discord-base-plugin.js';
export default class DiscordRoundWinner extends DiscordBasePlugin {
static get description() {
return 'The <code>DiscordRoundWinner</code> plugin will send the round winner to a Discord channel.';
}
static get defaultEnabled() {
return true;
}
static get optionsSpecification() {
return {
...DiscordBasePlugin.optionsSpecification,
channelID: {
required: true,
description: 'The ID of the channel to log admin broadcasts to.',
default: '',
example: '667741905228136459'
},
color: {
required: false,
description: 'The color of the embed.',
default: 16761867
}
};
}
constructor(server, options, optionsRaw) {
super(server, options, optionsRaw);
2020-10-21 14:28:29 -05:00
this.server.on('NEW_GAME', async (info) => {
2020-10-21 14:28:29 -05:00
await this.sendDiscordMessage({
embed: {
title: 'Round Winner',
2020-10-23 05:18:23 -05:00
color: this.options.color,
2020-10-21 14:28:29 -05:00
fields: [
{
name: 'Message',
value: `${info.winner} won on ${info.layer}.`
}
],
timestamp: info.time.toISOString()
}
});
});
}
}