2020-08-20 15:21:03 -05:00
|
|
|
export default {
|
|
|
|
name: 'discord-debug',
|
2020-08-22 08:32:39 -05:00
|
|
|
description:
|
2020-09-10 08:17:27 -05:00
|
|
|
'The <code>discord-debug</code> plugin can be used to help debug SquadJS by dumping SquadJS events to a ' +
|
|
|
|
'Discord channel.',
|
2020-05-15 12:42:39 -05:00
|
|
|
|
2020-08-22 10:54:05 -05:00
|
|
|
defaultEnabled: false,
|
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
|
|
|
},
|
|
|
|
events: {
|
|
|
|
required: true,
|
2020-09-10 08:17:27 -05:00
|
|
|
description: 'A list of events to dump.',
|
2020-08-20 15:21:03 -05:00
|
|
|
default: [],
|
2020-09-10 08:17:27 -05:00
|
|
|
example: ['PLAYER_DIED']
|
2020-08-20 15:21:03 -05:00
|
|
|
}
|
|
|
|
},
|
2020-05-15 12:42:39 -05:00
|
|
|
|
2020-08-20 15:21:03 -05:00
|
|
|
init: async (server, options) => {
|
|
|
|
const channel = await options.discordClient.channels.fetch(options.channelID);
|
2020-05-15 12:42:39 -05:00
|
|
|
|
2020-08-20 15:21:03 -05:00
|
|
|
for (const event of options.events) {
|
|
|
|
server.on(event, (info) => {
|
2020-09-02 07:20:07 -05:00
|
|
|
channel.send(`\`\`\`${JSON.stringify({ ...info, event }, null, 2)}\`\`\``);
|
2020-08-20 15:21:03 -05:00
|
|
|
});
|
|
|
|
}
|
2020-05-15 12:42:39 -05:00
|
|
|
}
|
2020-08-20 15:21:03 -05:00
|
|
|
};
|