SquadJS/squad-server/plugins/discord-placeholder.js

42 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-10-16 10:06:10 -05:00
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) {
2020-10-23 05:18:23 -05:00
super(server, options);
2020-10-16 10:06:10 -05:00
2020-10-23 05:18:23 -05:00
this.options.discordClient.on('message', async (message) => {
2020-10-16 10:06:10 -05:00
// check the author of the message is not a bot
2020-10-23 05:18:23 -05:00
if (message.author.bot || !message.content.toLowerCase().startsWith(this.options.command)) return;
2020-10-16 10:06:10 -05:00
2020-10-16 10:57:22 -05:00
await message.channel.send('Placeholder.');
2020-10-16 10:06:10 -05:00
});
}
}