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 chalk = require('chalk');
|
||||||
const { inspect } = require('util');
|
const { inspect } = require('util');
|
||||||
|
|
||||||
@ -25,10 +25,18 @@ const Constants = {
|
|||||||
class DiscordClient extends Client {
|
class DiscordClient extends Client {
|
||||||
|
|
||||||
constructor(options) {
|
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({
|
super({
|
||||||
...options.discord.clientOptions
|
...options.discord.clientOptions,
|
||||||
|
partials
|
||||||
});
|
});
|
||||||
|
|
||||||
this.logger = new Logger({ name: 'Client' });
|
this.logger = new Logger({ name: 'Client' });
|
||||||
|
@ -24,17 +24,13 @@ class CommandHandler extends Observer {
|
|||||||
|
|
||||||
async messageCreate(message) {
|
async messageCreate(message) {
|
||||||
|
|
||||||
console.log(message.content);
|
|
||||||
if(!this.client._built
|
if(!this.client._built
|
||||||
|| message.webhookId
|
|| message.webhookId
|
||||||
|| message.author.bot
|
|| message.author.bot
|
||||||
|| message.guild && !message.guild.available) return undefined;
|
|| message.guild && !message.guild.available) return undefined;
|
||||||
|
|
||||||
console.log(1);
|
|
||||||
|
|
||||||
const userWrapper = await this.client.getUserWrapper(message.author.id);
|
const userWrapper = await this.client.getUserWrapper(message.author.id);
|
||||||
if (!userWrapper.developer) return;
|
if (!userWrapper.developer) return;
|
||||||
console.log(2);
|
|
||||||
|
|
||||||
if(message.guild) {
|
if(message.guild) {
|
||||||
if(!message.member) await message.guild.members.fetch(message.author.id);
|
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);
|
const { command, parameters } = await this._getCommand(messageWrapper);
|
||||||
if (!command) return undefined;
|
if (!command) return undefined;
|
||||||
console.log(3);
|
|
||||||
|
|
||||||
const invoker = new InvokerWrapper(this.client, messageWrapper, command);
|
const invoker = new InvokerWrapper(this.client, messageWrapper, command);
|
||||||
const inhibitors = await this._handleInhibitors(invoker);
|
const inhibitors = await this._handleInhibitors(invoker);
|
||||||
@ -53,15 +48,12 @@ class CommandHandler extends Observer {
|
|||||||
if (silent.length && silent.some((i) => i.inhibitor.id === 'channelIgnore')
|
if (silent.length && silent.some((i) => i.inhibitor.id === 'channelIgnore')
|
||||||
|| nonsilent.length && nonsilent.some((i) => i.args.missing.includes('SendMessages'))
|
|| nonsilent.length && nonsilent.some((i) => i.args.missing.includes('SendMessages'))
|
||||||
|| silent.length && !nonsilent.length) return;
|
|| silent.length && !nonsilent.length) return;
|
||||||
console.log(4);
|
|
||||||
|
|
||||||
if (inhibitors.length) return this._generateError(invoker, { type: 'inhibitor', ...inhibitors[0] }).catch(this.logger.error);
|
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);
|
const response = await this._parseMessage(invoker, parameters);
|
||||||
// There was an error if _parseResponse return value is truthy, i.e. an error message was sent
|
// There was an error if _parseResponse return value is truthy, i.e. an error message was sent
|
||||||
if (await this._parseResponse(invoker, response)) return;
|
if (await this._parseResponse(invoker, response)) return;
|
||||||
console.log(6);
|
|
||||||
|
|
||||||
await this._executeCommand(invoker, command.slash ? response.options.args : response.options);
|
await this._executeCommand(invoker, command.slash ? response.options.args : response.options);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user