mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-24 10:25:11 +02:00
Fix
This commit is contained in:
@@ -23,9 +23,27 @@ module.exports = class NameRaterCommand extends Command {
|
|||||||
{
|
{
|
||||||
key: 'name',
|
key: 'name',
|
||||||
prompt: 'What name do you want to determine the quality of?',
|
prompt: 'What name do you want to determine the quality of?',
|
||||||
type: 'user|string',
|
type: 'string',
|
||||||
max: 25,
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user