galactic-bot/structure/client/components/observers/ImageRestriction.js

34 lines
819 B
JavaScript
Raw Normal View History

2021-06-18 00:16:28 +02:00
const { Observer } = require("../../../interfaces");
class RestrictedChannels extends Observer {
constructor(client) {
super(client, {
name: 'restrictedChannels',
priority: 0,
disabled: false
});
this.client = client;
this.hooks = [
['message', this.message.bind(this)]
];
}
async message(message) {
const { imageOnly } = await message.guild.settings();
if(!imageOnly.channels) return undefined;
if(imageOnly.channels.includes(message.channel.id)) {
if(message.attachments.size === 0 && message.embeds.length === 0) {
this.client.rateLimiter.queueDelete(message.channel, message);
}
}
}
}
module.exports = RestrictedChannels;