SquadJS/plugins/discord-debug/index.js

38 lines
999 B
JavaScript
Raw Normal View History

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
defaultEnabled: false,
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'
},
events: {
required: true,
2020-09-10 08:17:27 -05:00
description: 'A list of events to dump.',
default: [],
2020-09-10 08:17:27 -05:00
example: ['PLAYER_DIED']
}
},
2020-05-15 12:42:39 -05:00
init: async (server, options) => {
const channel = await options.discordClient.channels.fetch(options.channelID);
2020-05-15 12:42:39 -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-05-15 12:42:39 -05:00
}
};