forked from Galactic/modmail
misc fixes
This commit is contained in:
parent
781daf9545
commit
9676addad8
@ -75,7 +75,7 @@ class ModmailClient extends Client {
|
||||
ready () {
|
||||
|
||||
return new Promise((resolve) => {
|
||||
if (this._ready) resolve();
|
||||
if (this._ready) return 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;
|
@ -19,12 +19,13 @@ class CannedReply extends Command {
|
||||
anon = false;
|
||||
content = content.replace(`${this.client.prefix}${_caller}`, '');
|
||||
const op = args.shift().toLowerCase();
|
||||
|
||||
if (op === 'anon') {
|
||||
anon = true;
|
||||
content = content.replace(first, '');
|
||||
} else if ([ 'create', 'delete' ].includes(op)) {
|
||||
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);
|
||||
let str = '';
|
||||
@ -39,7 +40,9 @@ class CannedReply extends Command {
|
||||
}
|
||||
if (str.length) return channel.send(str);
|
||||
return '**__None__**';
|
||||
|
||||
}
|
||||
|
||||
return this.client.modmail.sendCannedResponse({ message, responseName: content.trim(), anon });
|
||||
|
||||
}
|
||||
|
@ -12,22 +12,11 @@ class ModmailID extends Command {
|
||||
async execute (message, { args }) {
|
||||
|
||||
let channel = null;
|
||||
if (args?.length) {
|
||||
const [ ch ] = args;
|
||||
channel = await this.client.resolveChannel(ch);
|
||||
} else {
|
||||
({ channel } = message);
|
||||
}
|
||||
if (args?.length) channel = await this.client.resolveChannel(args[0]);
|
||||
else ({ channel } = message);
|
||||
|
||||
const chCache = this.client.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]**`
|
||||
};
|
||||
const result = this.client.getUserFromChannel(channel);
|
||||
if (result.error) return result;
|
||||
|
||||
const [ userId ] = result;
|
||||
return userId;
|
||||
|
Loading…
Reference in New Issue
Block a user