This commit is contained in:
Dragon Fire
2021-03-08 20:27:28 -05:00
parent 4551accf87
commit bde9aeaa23
+20 -2
View File
@@ -23,9 +23,27 @@ module.exports = class NameRaterCommand extends Command {
{
key: 'name',
prompt: 'What name do you want to determine the quality of?',
type: 'user|string',
type: 'string',
max: 25,
default: msg => msg.author.username
default: msg => msg.author.username,
validate: name => {
const matches = name.match(/^(?:<@!?)?([0-9]+)>?$/);
if (matches) {
try {
const user = await this.client.users.fetch(matches[1]);
if (!user) return false;
return true;
} catch (err) {
return false;
}
}
return true;
},
parse: name => {
const matches = name.match(/^(?:<@!?)?([0-9]+)>?$/);
if (matches) return this.client.users.cache.get(matches[1]) || null;
return name;
}
}
]
});