From cc02562a38fc8a43c1f779127ec75045fc82979b Mon Sep 17 00:00:00 2001 From: Neko Life Date: Mon, 24 May 2021 13:39:14 +0000 Subject: [PATCH] Use regex --- cmds/utility/uinfo.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/cmds/utility/uinfo.js b/cmds/utility/uinfo.js index 02b5834..73658a6 100644 --- a/cmds/utility/uinfo.js +++ b/cmds/utility/uinfo.js @@ -1,7 +1,7 @@ 'use strict'; const commando = require("@iceprod/discord.js-commando"); -const { getUser, errLog, ranLog, trySend } = require("../../resources/functions"); +const { ranLog, trySend, cleanMentionID, findMemberRegEx } = require("../../resources/functions"); module.exports = class uinfo extends commando.Command { constructor(client) { @@ -12,12 +12,17 @@ module.exports = class uinfo extends commando.Command { description: "\"Detailed\" Profile." }); } - async run(msg, arg ) { - const args = arg.trim().split(/ +/); + async run(msg, arg) { try { - let profile; - if (args[0]) { - profile = await getUser(this.client, msg, args[0]); + let profile, + hmm; + if (arg.length > 0) { + hmm = cleanMentionID(arg); + if (/^\d{17,19}$/.test(hmm)) { + profile = this.client.users.cache.get(hmm); + } else { + profile = findMemberRegEx(msg, hmm)[0].user; + } } else { profile = msg.author; } @@ -35,7 +40,7 @@ module.exports = class uinfo extends commando.Command { trySend(this.client, msg, result, {split:{maxLength:2000,char: ", " || ",\n" || ". " || ".\n" || "," || ".",append:',```',prepend:'```js\n'}}); return ranLog(msg,'profile', msg.content); } catch (e) { - return errLog(e, msg, this.client, false, 'Gimme the right ID!', true); + return trySend(this.client, msg, "Ya lookin for ya lover? 404 not found."); } } }; \ No newline at end of file