SquadJS/plugins/discord-admin-broadcast/index.js

54 lines
1.4 KiB
JavaScript
Raw Normal View History

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
export default {
name: 'discord-admin-broadcast',
2020-08-22 08:32:39 -05:00
description:
'The `discord-admin-broadcast` plugin will send a copy of admin broadcasts made in game to a Discord channel.',
2020-07-14 14:17:10 -05:00
defaultEnabled: true,
optionsSpec: {
discordClient: {
type: 'DiscordConnector',
required: true,
default: 'discord',
description: 'The name of the Discord Connector to use.'
},
channelID: {
type: 'Discord Channel ID',
required: true,
default: 'Discord Channel ID',
description: 'The ID of the channel to log admin broadcasts to.'
},
color: {
type: 'Discord Color Code',
required: false,
default: 16761867,
description: 'The color of the embed.'
}
},
2020-07-14 14:17:10 -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) => {
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-07-14 14:17:10 -05:00
});
}
};