userinfo: use lookupUser

This commit is contained in:
Cynthia Foxwell 2024-08-14 10:58:00 -06:00
parent 3a864466cf
commit a5da10b6aa

View file

@ -11,13 +11,11 @@ const {
ClanPlaystyle,
UserFlags,
} = require("@util/dconstants.js");
const {
RegExp: {Snowflake: SNOWFLAKE_REGEX},
Icons,
} = require("@util/constants.js");
const {Icons} = require("@util/constants.js");
const {formatUsername, getDefaultAvatar, getTopColor, pastelize} = require("@util/misc.js");
const {snowflakeToTimestamp} = require("@util/time.js");
const {lookupUser} = require("@util/selection.js");
const ONE_MONTH = 2628000;
@ -35,8 +33,12 @@ userinfo.callback = async function (msg, line) {
if (!line || line == "") {
id = msg.author?.id ?? msg.user?.id;
} else {
if (!SNOWFLAKE_REGEX.test(line)) return "Not a snowflake.";
id = line.match(SNOWFLAKE_REGEX)[1];
const lookup = await lookupUser(msg, user);
if (lookup == "No results" || lookup == "Canceled" || lookup == "Request timed out") {
return lookup;
} else {
id = lookup.id;
}
}
if (!id) return "Failed to get ID somehow.";