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

53 lines
1.3 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:
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
defaultEnabled: true,
optionsSpec: {
discordClient: {
required: true,
2020-09-10 08:17:27 -05:00
description: 'The name of the Discord Connector to use.',
default: 'discord'
},
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'
},
color: {
required: false,
2020-09-10 08:17:27 -05:00
description: 'The color of the embed.',
default: 16761867
}
},
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
});
}
};