propigate errors from lookupUser
This commit is contained in:
parent
83c49eb6ae
commit
5b8a9afbaa
6 changed files with 10 additions and 6 deletions
|
@ -48,7 +48,7 @@ avatar.callback = async function (msg, line, [user], {server, guild}) {
|
|||
}
|
||||
} else if (user) {
|
||||
const lookup = await lookupUser(msg, user);
|
||||
if (lookup == "No results" || lookup == "Canceled" || lookup == "Request timed out") {
|
||||
if (typeof lookup === "string") {
|
||||
return lookup;
|
||||
} else {
|
||||
id = lookup.id;
|
||||
|
|
|
@ -44,7 +44,7 @@ banner.callback = async function (msg, line, [user], {server, guild}) {
|
|||
}
|
||||
} else if (user) {
|
||||
const lookup = await lookupUser(msg, user);
|
||||
if (lookup == "No results" || lookup == "Canceled" || lookup == "Request timed out") {
|
||||
if (typeof lookup === "string") {
|
||||
return lookup;
|
||||
} else {
|
||||
id = lookup.id;
|
||||
|
|
|
@ -15,7 +15,7 @@ decoration.callback = async function (msg, line, [user]) {
|
|||
|
||||
if (user) {
|
||||
const lookup = await lookupUser(msg, user);
|
||||
if (lookup == "No results" || lookup == "Canceled" || lookup == "Request timed out") {
|
||||
if (typeof lookup === "string") {
|
||||
return lookup;
|
||||
} else {
|
||||
id = lookup.id;
|
||||
|
|
|
@ -52,7 +52,7 @@ presence.callback = async function (msg, line) {
|
|||
let target;
|
||||
if (line) {
|
||||
const user = await lookupUser(msg, line);
|
||||
if (user == "No results" || user == "Canceled" || user == "Request timed out") {
|
||||
if (typeof user === "string") {
|
||||
return user;
|
||||
} else {
|
||||
let member = user;
|
||||
|
|
|
@ -70,7 +70,7 @@ userinfo.callback = async function (msg, line) {
|
|||
id = msg.author?.id ?? msg.user?.id;
|
||||
} else {
|
||||
const lookup = await lookupUser(msg, line);
|
||||
if (lookup == "No results" || lookup == "Canceled" || lookup == "Request timed out") {
|
||||
if (typeof lookup === "string") {
|
||||
return lookup;
|
||||
} else {
|
||||
id = lookup.id;
|
||||
|
|
|
@ -112,7 +112,11 @@ async function selectionMessage(msg, heading, options, timeout = 30000, maxItems
|
|||
|
||||
async function lookupUser(msg, str, filter) {
|
||||
if (REGEX_SNOWFLAKE.test(str)) {
|
||||
return await hf.bot.requestHandler.request("GET", APIEndpoints.USER(str.match(REGEX_SNOWFLAKE)[1]), true);
|
||||
try {
|
||||
return await hf.bot.requestHandler.request("GET", APIEndpoints.USER(str.match(REGEX_SNOWFLAKE)[1]), true);
|
||||
} catch (err) {
|
||||
return err.message;
|
||||
}
|
||||
}
|
||||
|
||||
let users;
|
||||
|
|
Loading…
Reference in a new issue