SquadJS/squad-server/plugins/discord-base-plugin.js

28 lines
711 B
JavaScript
Raw Normal View History

2020-10-13 06:59:07 -05:00
import BasePlugin from './base-plugin.js';
import { COPYRIGHT_MESSAGE } from '../utils/constants.js';
2020-10-13 06:59:07 -05:00
export default class DiscordBasePlugin extends BasePlugin {
static get optionsSpecification() {
return {
discordClient: {
required: true,
description: 'Discord connector name.',
connector: 'discord',
default: 'discord'
}
};
}
2020-12-03 08:16:07 -06:00
async prepareToMount() {
this.channel = await this.options.discordClient.channels.fetch(this.options.channelID);
2020-10-13 06:59:07 -05:00
}
2020-12-03 08:16:07 -06:00
async sendDiscordMessage(message) {
2020-12-06 15:23:05 -06:00
if (typeof message === 'object' && 'embed' in message)
message.embed.footer = { text: COPYRIGHT_MESSAGE };
2020-10-13 06:59:07 -05:00
await this.channel.send(message);
}
}