diff --git a/src/lib/utils.js b/src/lib/utils.js
index fd3f0d3..7b6902b 100644
--- a/src/lib/utils.js
+++ b/src/lib/utils.js
@@ -79,8 +79,8 @@ async function findLastImage(msg, gif = false) {
let img;
for (const message of messages) {
- if (message.attachments.length > 0) {
- img = message.attachments[0].url;
+ if (message.attachments.size > 0) {
+ img = [...msg.attachments.values()][0].url;
if (gif && (await isGif(img))) {
break;
} else {
@@ -112,8 +112,9 @@ const urlRegex = /((https?):\/)?\/?([^:/\s]+)((\/\w+)*\/)([\w\-.]+)/;
async function getImage(msg, str) {
const refMsg = msg.referencedMessage;
if (refMsg) {
- if (refMsg.attachments[0] && refMsg.attachments[0].url) {
- return refMsg.attachments[0].url;
+ const attachments = [...refMsg.attachments.values()];
+ if (attachments[0]?.url) {
+ return attachments[0].url;
} else if (//.test(refMsg.content)) {
const id = refMsg.content.match(//)[1];
return `https://cdn.discordapp.com/emojis/${id}.png?v=1`;
@@ -134,8 +135,9 @@ async function getImage(msg, str) {
if (img) return img;
}
- if (msg.attachments[0] && msg.attachments[0].url) {
- return msg.attachments[0].url;
+ const attachments = [...msg.attachments.values()];
+ if (attachments[0]?.url) {
+ return attachments[0]?.url;
} else if (urlRegex.test(str)) {
return str;
} else if (//.test(str)) {