2020-08-20 15:21:03 -05:00
|
|
|
import { COPYRIGHT_MESSAGE } from 'core/constants';
|
2020-09-09 03:31:48 -05:00
|
|
|
import { ADMIN_BROADCAST } from 'squad-server/events';
|
2020-07-14 14:17:10 -05:00
|
|
|
|
2020-08-20 15:21:03 -05:00
|
|
|
export default {
|
|
|
|
name: 'discord-admin-broadcast',
|
2020-08-22 08:32:39 -05:00
|
|
|
description:
|
2020-09-10 08:17:27 -05:00
|
|
|
'The <code>discord-admin-broadcast</code> plugin will send a copy of admin broadcasts made in game to a Discord ' +
|
|
|
|
'channel.',
|
2020-07-14 14:17:10 -05:00
|
|
|
|
2020-08-22 10:54:05 -05:00
|
|
|
defaultEnabled: true,
|
2020-08-20 15:21:03 -05:00
|
|
|
optionsSpec: {
|
|
|
|
discordClient: {
|
|
|
|
required: true,
|
2020-09-10 08:17:27 -05:00
|
|
|
description: 'The name of the Discord Connector to use.',
|
|
|
|
default: 'discord'
|
2020-08-20 15:21:03 -05:00
|
|
|
},
|
|
|
|
channelID: {
|
|
|
|
required: true,
|
2020-09-10 08:17:27 -05:00
|
|
|
description: 'The ID of the channel to log admin broadcasts to.',
|
|
|
|
default: '',
|
|
|
|
example: '667741905228136459'
|
2020-08-20 15:21:03 -05:00
|
|
|
},
|
|
|
|
color: {
|
|
|
|
required: false,
|
2020-09-10 08:17:27 -05:00
|
|
|
description: 'The color of the embed.',
|
|
|
|
default: 16761867
|
2020-08-20 15:21:03 -05:00
|
|
|
}
|
|
|
|
},
|
2020-07-14 14:17:10 -05:00
|
|
|
|
2020-08-20 15:21:03 -05:00
|
|
|
init: async (server, options) => {
|
|
|
|
const channel = await options.discordClient.channels.fetch(options.channelID);
|
2020-07-14 14:17:10 -05:00
|
|
|
|
2020-09-09 03:31:48 -05:00
|
|
|
server.on(ADMIN_BROADCAST, async (info) => {
|
2020-08-20 15:21:03 -05:00
|
|
|
channel.send({
|
|
|
|
embed: {
|
|
|
|
title: 'Admin Broadcast',
|
|
|
|
color: options.color,
|
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
name: 'Message',
|
|
|
|
value: `${info.message}`
|
|
|
|
}
|
|
|
|
],
|
|
|
|
timestamp: info.time.toISOString(),
|
|
|
|
footer: {
|
|
|
|
text: COPYRIGHT_MESSAGE
|
2020-07-14 14:17:10 -05:00
|
|
|
}
|
|
|
|
}
|
2020-08-20 15:21:03 -05:00
|
|
|
});
|
2020-07-14 14:17:10 -05:00
|
|
|
});
|
2020-08-20 15:21:03 -05:00
|
|
|
}
|
|
|
|
};
|