SquadJS/squad-server/plugins/discord-placeholder.js
2020-10-23 11:29:38 +01:00

43 lines
1.1 KiB
JavaScript

import BasePlugin from './base-plugin.js';
export default class DiscordPlaceholder extends BasePlugin {
static get description() {
return (
'The <code>DiscordPlaceholder</code> plugin can be used to create placeholder messages in Discord for use by ' +
'other plugins.'
);
}
static get defaultEnabled() {
return true;
}
static get optionsSpecification() {
return {
discordClient: {
required: true,
description: 'Discord connector name.',
connector: 'discord',
default: 'discord'
},
command: {
required: false,
description: 'Command that triggers the placeholder message.',
default: '!placeholder'
}
};
}
constructor(server, options, optionsRaw) {
super(server, options, optionsRaw);
this.options.discordClient.on('message', async (message) => {
// check the author of the message is not a bot
if (message.author.bot || !message.content.toLowerCase().startsWith(this.options.command))
return;
await message.channel.send('Placeholder.');
});
}
}