From 0c7ae08315957b17e75d4847983040342b8601a1 Mon Sep 17 00:00:00 2001 From: nolan Date: Thu, 17 Jun 2021 15:16:28 -0700 Subject: [PATCH] shitty image only testing for now --- .../components/observers/ImageRestriction.js | 34 ++++++++++++ .../components/settings/utility/ImageOnly.js | 52 +++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 structure/client/components/observers/ImageRestriction.js create mode 100644 structure/client/components/settings/utility/ImageOnly.js diff --git a/structure/client/components/observers/ImageRestriction.js b/structure/client/components/observers/ImageRestriction.js new file mode 100644 index 0000000..5bb41f6 --- /dev/null +++ b/structure/client/components/observers/ImageRestriction.js @@ -0,0 +1,34 @@ +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; \ No newline at end of file diff --git a/structure/client/components/settings/utility/ImageOnly.js b/structure/client/components/settings/utility/ImageOnly.js new file mode 100644 index 0000000..41301d3 --- /dev/null +++ b/structure/client/components/settings/utility/ImageOnly.js @@ -0,0 +1,52 @@ +const { Setting } = require('../../../../interfaces/'); + +class ImageOnlySetting extends Setting { + + constructor(client) { + + super(client, { + name: 'imageOnly', + index: 'imageOnly', + module: 'utility', + resolve: 'GUILD', + default: { + imageOnly: { + channels: [] + } + } + }); + + } + + async handle(message, params) { + + const { imageOnly } = message.guild._settings; + + const result = await this.client.resolver.list( + imageOnly.channels, + message.guild.channels.cache.filter((c) => c.type === 'text').map((c) => c.id), + params, + this.client.resolver.resolveChannels.bind(this.client.resolver), + true, + message.guild + ); + + await message.guild._updateSettings({ + [this.index]: { + channels: result.list + } + }); + + } + + fields(guild) { + return { + name: '》 Channels', + value: `\`${guild._settings.imageOnly.channels}\`` + }; + } + + +} + +module.exports = ImageOnlySetting; \ No newline at end of file