misc fixes
This commit is contained in:
parent
0d62a410ad
commit
346707d5da
@ -14,7 +14,7 @@ class Registry {
|
|||||||
|
|
||||||
find(name) {
|
find(name) {
|
||||||
|
|
||||||
return this.commands.find((c) => c.name === name || c.aliases?.includes(name));
|
return this.commands.find((c) => c.name === name.toLowerCase() || c.aliases?.includes(name.toLowerCase()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +72,70 @@ class Resolver {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve multiple channels
|
||||||
|
*
|
||||||
|
* @param {Array<String>} [resolveables=[]] an array of channel resolveables (name, id)
|
||||||
|
* @param {Guild} guild the guild in which to look for channels
|
||||||
|
* @param {Boolean} [strict=false] whether or not partial names are resolved
|
||||||
|
* @param {Function} [filter=()] filter the resolving channels
|
||||||
|
* @returns {Promise<Array<GuildChannel>> || Promise<Boolean>} an array of guild channels or false if none were resolved
|
||||||
|
* @memberof Resolver
|
||||||
|
*/
|
||||||
|
async resolveChannels(resolveables = [], strict = false, guild = null, filter = () => true) {
|
||||||
|
|
||||||
|
if (typeof resolveables === 'string') resolveables = [resolveables];
|
||||||
|
if (resolveables.length === 0) return false;
|
||||||
|
if (!guild) return false;
|
||||||
|
const CM = guild.channels;
|
||||||
|
const resolved = [];
|
||||||
|
|
||||||
|
for (const resolveable of resolveables) {
|
||||||
|
const channel = CM.resolve(resolveable);
|
||||||
|
if (channel && filter(channel)) {
|
||||||
|
resolved.push(channel);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const name = /^#?([a-z0-9\-_0]+)/iu;
|
||||||
|
const id = /^<?#?([0-9]{17,22})>?/iu;
|
||||||
|
|
||||||
|
if (id.test(resolveable)) {
|
||||||
|
const match = resolveable.match(id);
|
||||||
|
const [, ch] = match;
|
||||||
|
|
||||||
|
const channel = await this.client.channels.fetch(ch).catch((e) => { }); //eslint-disable-line no-empty, no-empty-function, no-unused-vars
|
||||||
|
|
||||||
|
if (channel && filter(channel)) resolved.push(channel);
|
||||||
|
|
||||||
|
} else if (name.test(resolveable)) {
|
||||||
|
const match = resolveable.match(name);
|
||||||
|
const ch = match[1].toLowerCase();
|
||||||
|
|
||||||
|
const channel = CM.cache.sort((a, b) => a.name.length - b.name.length).filter(filter).filter((c) => {
|
||||||
|
if (!strict) return c.name.toLowerCase().includes(ch);
|
||||||
|
return c.name.toLowerCase() === ch;
|
||||||
|
}).first();
|
||||||
|
|
||||||
|
if (channel) resolved.push(channel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return resolved.length > 0 ? resolved : false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async resolveChannel(resolveable, strict, guild, filter) {
|
||||||
|
|
||||||
|
if (!resolveable) return false;
|
||||||
|
if (resolveable instanceof Array) throw new Error('Resolveable cannot be of type Array, use resolveChannels for resolving arrays of channels');
|
||||||
|
const result = await this.resolveChannels([resolveable], strict, guild, filter);
|
||||||
|
return result ? result[0] : false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Resolver;
|
module.exports = Resolver;
|
@ -14,6 +14,7 @@ class Eval extends Command {
|
|||||||
|
|
||||||
async execute(message, { clean }) {
|
async execute(message, { clean }) {
|
||||||
|
|
||||||
|
if (!this.client._options.evalAccess.includes(message.author.id)) return;
|
||||||
const { guild, author, member, client, channel } = message; //eslint-disable-line no-unused-vars
|
const { guild, author, member, client, channel } = message; //eslint-disable-line no-unused-vars
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -8,9 +8,9 @@ class Markread extends Command {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(message) {
|
async execute(message, { args }) {
|
||||||
|
|
||||||
return this.client.modmail.markread(message);
|
return this.client.modmail.markread(message, args);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class Modmail extends Command {
|
|||||||
first = second;
|
first = second;
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = await this.client.resolveUser(first);
|
const user = await this.client.resolveUser(first, true);
|
||||||
if (!user) return {
|
if (!user) return {
|
||||||
error: true,
|
error: true,
|
||||||
msg: 'Failed to resolve user'
|
msg: 'Failed to resolve user'
|
||||||
|
Loading…
Reference in New Issue
Block a user