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) {
|
} else if (user) {
|
||||||
const lookup = await lookupUser(msg, user);
|
const lookup = await lookupUser(msg, user);
|
||||||
if (lookup == "No results" || lookup == "Canceled" || lookup == "Request timed out") {
|
if (typeof lookup === "string") {
|
||||||
return lookup;
|
return lookup;
|
||||||
} else {
|
} else {
|
||||||
id = lookup.id;
|
id = lookup.id;
|
||||||
|
|
|
@ -44,7 +44,7 @@ banner.callback = async function (msg, line, [user], {server, guild}) {
|
||||||
}
|
}
|
||||||
} else if (user) {
|
} else if (user) {
|
||||||
const lookup = await lookupUser(msg, user);
|
const lookup = await lookupUser(msg, user);
|
||||||
if (lookup == "No results" || lookup == "Canceled" || lookup == "Request timed out") {
|
if (typeof lookup === "string") {
|
||||||
return lookup;
|
return lookup;
|
||||||
} else {
|
} else {
|
||||||
id = lookup.id;
|
id = lookup.id;
|
||||||
|
|
|
@ -15,7 +15,7 @@ decoration.callback = async function (msg, line, [user]) {
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
const lookup = await lookupUser(msg, user);
|
const lookup = await lookupUser(msg, user);
|
||||||
if (lookup == "No results" || lookup == "Canceled" || lookup == "Request timed out") {
|
if (typeof lookup === "string") {
|
||||||
return lookup;
|
return lookup;
|
||||||
} else {
|
} else {
|
||||||
id = lookup.id;
|
id = lookup.id;
|
||||||
|
|
|
@ -52,7 +52,7 @@ presence.callback = async function (msg, line) {
|
||||||
let target;
|
let target;
|
||||||
if (line) {
|
if (line) {
|
||||||
const user = await lookupUser(msg, line);
|
const user = await lookupUser(msg, line);
|
||||||
if (user == "No results" || user == "Canceled" || user == "Request timed out") {
|
if (typeof user === "string") {
|
||||||
return user;
|
return user;
|
||||||
} else {
|
} else {
|
||||||
let member = user;
|
let member = user;
|
||||||
|
|
|
@ -70,7 +70,7 @@ userinfo.callback = async function (msg, line) {
|
||||||
id = msg.author?.id ?? msg.user?.id;
|
id = msg.author?.id ?? msg.user?.id;
|
||||||
} else {
|
} else {
|
||||||
const lookup = await lookupUser(msg, line);
|
const lookup = await lookupUser(msg, line);
|
||||||
if (lookup == "No results" || lookup == "Canceled" || lookup == "Request timed out") {
|
if (typeof lookup === "string") {
|
||||||
return lookup;
|
return lookup;
|
||||||
} else {
|
} else {
|
||||||
id = lookup.id;
|
id = lookup.id;
|
||||||
|
|
|
@ -112,7 +112,11 @@ async function selectionMessage(msg, heading, options, timeout = 30000, maxItems
|
||||||
|
|
||||||
async function lookupUser(msg, str, filter) {
|
async function lookupUser(msg, str, filter) {
|
||||||
if (REGEX_SNOWFLAKE.test(str)) {
|
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;
|
let users;
|
||||||
|
|
Loading…
Reference in a new issue