Use regex

This commit is contained in:
Neko Life 2021-05-24 13:39:14 +00:00
parent bfff9e5610
commit cc02562a38

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
const commando = require("@iceprod/discord.js-commando"); 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 { module.exports = class uinfo extends commando.Command {
constructor(client) { constructor(client) {
@ -12,12 +12,17 @@ module.exports = class uinfo extends commando.Command {
description: "\"Detailed\" Profile." description: "\"Detailed\" Profile."
}); });
} }
async run(msg, arg ) { async run(msg, arg) {
const args = arg.trim().split(/ +/);
try { try {
let profile; let profile,
if (args[0]) { hmm;
profile = await getUser(this.client, msg, args[0]); 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 { } else {
profile = msg.author; 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'}}); trySend(this.client, msg, result, {split:{maxLength:2000,char: ", " || ",\n" || ". " || ".\n" || "," || ".",append:',```',prepend:'```js\n'}});
return ranLog(msg,'profile', msg.content); return ranLog(msg,'profile', msg.content);
} catch (e) { } 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.");
} }
} }
}; };