From bde9aeaa237998eb73cea339cfe826a08480ed86 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Mon, 8 Mar 2021 20:27:28 -0500 Subject: [PATCH] Fix --- commands/random-seed/name-rater.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/commands/random-seed/name-rater.js b/commands/random-seed/name-rater.js index d818bcac..a73896d3 100644 --- a/commands/random-seed/name-rater.js +++ b/commands/random-seed/name-rater.js @@ -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; + } } ] });