forked from Galactic/galactic-bot
channel partial
This commit is contained in:
parent
29aebdf22e
commit
675762f738
@ -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' });
|
||||
|
@ -24,17 +24,13 @@ 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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user