diff --git a/src/lib/utils.js b/src/lib/utils.js
index 7b6902b..65e9781 100644
--- a/src/lib/utils.js
+++ b/src/lib/utils.js
@@ -70,7 +70,9 @@ function readableTime(number) {
}
async function isGif(url) {
- const type = await fetch(url).then((res) => res.headers.get("Content-Type"));
+ const type = await fetch(url, {method: "HEAD"}).then((res) =>
+ res.headers.get("Content-Type")
+ );
return type == "image/gif";
}
@@ -115,11 +117,11 @@ async function getImage(msg, str) {
const attachments = [...refMsg.attachments.values()];
if (attachments[0]?.url) {
return attachments[0].url;
- } else if (//.test(refMsg.content)) {
- const id = refMsg.content.match(//)[1];
+ } else if (//.test(refMsg.content)) {
+ const id = refMsg.content.match(//)[1];
return `https://cdn.discordapp.com/emojis/${id}.png?v=1`;
- } else if (/<@!?([0-9]*)>/.test(refMsg.content)) {
- const id = refMsg.content.match(/<@!?([0-9]*)>/)[1];
+ } else if (/<@!?([0-9]+)>/.test(refMsg.content)) {
+ const id = refMsg.content.match(/<@!?([0-9]+)>/)[1];
const user = await hf.bot.requestHandler.request(
"GET",
"/users/" + id,
@@ -140,11 +142,11 @@ async function getImage(msg, str) {
return attachments[0]?.url;
} else if (urlRegex.test(str)) {
return str;
- } else if (//.test(str)) {
- const id = str.match(//)[1];
+ } else if (//.test(str)) {
+ const id = str.match(//)[1];
return `https://cdn.discordapp.com/emojis/${id}.png?v=1`;
- } else if (/<@!?([0-9]*)>/.test(str)) {
- const id = str.match(/<@!?([0-9]*)>/)[1];
+ } else if (/<@!?([0-9]+)>/.test(str)) {
+ const id = str.match(/<@!?([0-9]+)>/)[1];
const user = await hf.bot.requestHandler.request(
"GET",
"/users/" + id,
@@ -325,12 +327,20 @@ async function lookupUser(msg, str, filter) {
return user;
} else if (
user.username.toLowerCase().indexOf(str.toLowerCase()) > -1 ||
- (user.nick && user.nick.indexOf(str.toLowerCase()) > -1)
+ (user.nick && user.nick.toLowerCase().indexOf(str.toLowerCase()) > -1) ||
+ (user.globalName &&
+ user.globalName.toLowerCase().indexOf(str.toLowerCase()) > -1)
) {
selection.push({
value: user,
key: user.id,
- display: `${formatUsername(user)}${user.nick ? ` (${user.nick})` : ""}`,
+ display: `${formatUsername(user)}${
+ user.nick
+ ? ` (${user.nick})`
+ : user.globalName
+ ? ` (${user.globalName})`
+ : ""
+ }`,
});
}
}