forked from Galactic/modmail
misc fixes
This commit is contained in:
parent
781daf9545
commit
9676addad8
@ -75,7 +75,7 @@ class ModmailClient extends Client {
|
|||||||
ready () {
|
ready () {
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
if (this._ready) resolve();
|
if (this._ready) return resolve();
|
||||||
this.once('ready', resolve);
|
this.once('ready', resolve);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -165,6 +165,22 @@ class ModmailClient extends Client {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getUserFromChannel (channel) {
|
||||||
|
|
||||||
|
const chCache = this.cache.channels;
|
||||||
|
const result = Object.entries(chCache).find(([ , val ]) => {
|
||||||
|
return val === channel.id;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!result) return {
|
||||||
|
error: true,
|
||||||
|
msg: `This doesn't seem to be a valid modmail channel. Cache might be out of sync. **[MISSING TARGET]**`
|
||||||
|
};
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = ModmailClient;
|
module.exports = ModmailClient;
|
@ -19,12 +19,13 @@ class CannedReply extends Command {
|
|||||||
anon = false;
|
anon = false;
|
||||||
content = content.replace(`${this.client.prefix}${_caller}`, '');
|
content = content.replace(`${this.client.prefix}${_caller}`, '');
|
||||||
const op = args.shift().toLowerCase();
|
const op = args.shift().toLowerCase();
|
||||||
|
|
||||||
if (op === 'anon') {
|
if (op === 'anon') {
|
||||||
anon = true;
|
anon = true;
|
||||||
content = content.replace(first, '');
|
content = content.replace(first, '');
|
||||||
} else if ([ 'create', 'delete' ].includes(op)) {
|
} else if ([ 'create', 'delete' ].includes(op)) {
|
||||||
return this.createCanned(op, args, message);
|
return this.createCanned(op, args, message);
|
||||||
} else if ([ 'list' ].includes(first.toLowerCase(op))) {
|
} else if ([ 'list' ].includes(first.toLowerCase())) {
|
||||||
|
|
||||||
const list = Object.entries(this.client.modmail.replies);
|
const list = Object.entries(this.client.modmail.replies);
|
||||||
let str = '';
|
let str = '';
|
||||||
@ -39,7 +40,9 @@ class CannedReply extends Command {
|
|||||||
}
|
}
|
||||||
if (str.length) return channel.send(str);
|
if (str.length) return channel.send(str);
|
||||||
return '**__None__**';
|
return '**__None__**';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.client.modmail.sendCannedResponse({ message, responseName: content.trim(), anon });
|
return this.client.modmail.sendCannedResponse({ message, responseName: content.trim(), anon });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,22 +12,11 @@ class ModmailID extends Command {
|
|||||||
async execute (message, { args }) {
|
async execute (message, { args }) {
|
||||||
|
|
||||||
let channel = null;
|
let channel = null;
|
||||||
if (args?.length) {
|
if (args?.length) channel = await this.client.resolveChannel(args[0]);
|
||||||
const [ ch ] = args;
|
else ({ channel } = message);
|
||||||
channel = await this.client.resolveChannel(ch);
|
|
||||||
} else {
|
|
||||||
({ channel } = message);
|
|
||||||
}
|
|
||||||
|
|
||||||
const chCache = this.client.cache.channels;
|
const result = this.client.getUserFromChannel(channel);
|
||||||
const result = Object.entries(chCache).find(([ , val ]) => {
|
if (result.error) return result;
|
||||||
return val === channel.id;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!result) return {
|
|
||||||
error: true,
|
|
||||||
msg: `This doesn't seem to be a valid modmail channel. Cache might be out of sync. **[MISSING TARGET]**`
|
|
||||||
};
|
|
||||||
|
|
||||||
const [ userId ] = result;
|
const [ userId ] = result;
|
||||||
return userId;
|
return userId;
|
||||||
|
Loading…
Reference in New Issue
Block a user