SquadJS/plugins/discord-debug/index.js

37 lines
920 B
JavaScript
Raw Normal View History

export default {
name: 'discord-debug',
description: 'Dump SquadJS events to Discord.',
defaultDisabled: true,
2020-05-15 12:42:39 -05:00
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.'
},
events: {
type: 'Array',
required: true,
default: [],
description: 'A list of events to dump.'
}
},
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) => {
channel.send(`\`\`\`${JSON.stringify(info, null, 2)}\`\`\``);
});
}
2020-05-15 12:42:39 -05:00
}
};