From 675762f738ad355299e889cfd29f34639ca82dc6 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Sun, 24 Jul 2022 01:55:26 +0300 Subject: [PATCH] channel partial --- src/structure/DiscordClient.js | 14 +++++++++++--- .../components/observers/CommandHandler.js | 10 +--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/structure/DiscordClient.js b/src/structure/DiscordClient.js index a1ff2ac..e59a8c1 100644 --- a/src/structure/DiscordClient.js +++ b/src/structure/DiscordClient.js @@ -1,4 +1,4 @@ -const { Client, Collection, DataResolver, ActivityType } = require('discord.js'); +const { Client, Collection, DataResolver, ActivityType, Partials } = require('discord.js'); const chalk = require('chalk'); const { inspect } = require('util'); @@ -25,10 +25,18 @@ const Constants = { class DiscordClient extends Client { constructor(options) { - if(!options) return null; + if (!options) return null; + + const partials = []; + for (const partial of options.discord.clientOptions.partials) { + if(partial in Partials) + partials.push(Partials[partial]); + else throw new Error(`Invalid partial ${partial}`); + } super({ - ...options.discord.clientOptions + ...options.discord.clientOptions, + partials }); this.logger = new Logger({ name: 'Client' }); diff --git a/src/structure/components/observers/CommandHandler.js b/src/structure/components/observers/CommandHandler.js index f6cb61c..6ea421d 100644 --- a/src/structure/components/observers/CommandHandler.js +++ b/src/structure/components/observers/CommandHandler.js @@ -24,18 +24,14 @@ class CommandHandler extends Observer { async messageCreate(message) { - console.log(message.content); if(!this.client._built || message.webhookId || message.author.bot || message.guild && !message.guild.available) return undefined; - console.log(1); - const userWrapper = await this.client.getUserWrapper(message.author.id); if (!userWrapper.developer) return; - console.log(2); - + if(message.guild) { if(!message.member) await message.guild.members.fetch(message.author.id); } @@ -44,7 +40,6 @@ class CommandHandler extends Observer { const { command, parameters } = await this._getCommand(messageWrapper); if (!command) return undefined; - console.log(3); const invoker = new InvokerWrapper(this.client, messageWrapper, command); const inhibitors = await this._handleInhibitors(invoker); @@ -53,15 +48,12 @@ class CommandHandler extends Observer { if (silent.length && silent.some((i) => i.inhibitor.id === 'channelIgnore') || nonsilent.length && nonsilent.some((i) => i.args.missing.includes('SendMessages')) || silent.length && !nonsilent.length) return; - console.log(4); if (inhibitors.length) return this._generateError(invoker, { type: 'inhibitor', ...inhibitors[0] }).catch(this.logger.error); - console.log(5); const response = await this._parseMessage(invoker, parameters); // There was an error if _parseResponse return value is truthy, i.e. an error message was sent if (await this._parseResponse(invoker, response)) return; - console.log(6); await this._executeCommand(invoker, command.slash ? response.options.args : response.options);