diff --git a/commands/avatar.js b/commands/avatar.js index ed1c722..fe3a6d8 100644 --- a/commands/avatar.js +++ b/commands/avatar.js @@ -5,6 +5,12 @@ exports.run = async (message, args) => { return message.mentions[0].avatarURL; } else if (client.users.get(args[0]) !== undefined) { return client.users.get(args[0]).avatarURL; + } else if (args.join(" ") !== "") { + const userRegex = new RegExp(args.join("|"), "i"); + const member = message.channel.guild.members.find(element => { + return userRegex.test(element.nick) ? userRegex.test(element.nick) : userRegex.test(element.username); + }); + return member ? member.avatarURL : message.author.avatarURL; } else { return message.author.avatarURL; } diff --git a/commands/help.js b/commands/help.js index 41e1786..7a1c004 100644 --- a/commands/help.js +++ b/commands/help.js @@ -105,6 +105,7 @@ exports.run = async (message, args) => { } }; +exports.aliases = ["commands"]; exports.category = 1; exports.help = "Gets a list of commands"; exports.params = "{command}"; \ No newline at end of file diff --git a/utils/imagedetect.js b/utils/imagedetect.js index c0d7f36..d5c27af 100644 --- a/utils/imagedetect.js +++ b/utils/imagedetect.js @@ -1,5 +1,6 @@ const fetch = require("node-fetch"); const fileType = require("file-type"); +const urlRegex = /(?:\w+:)?\/\/(\S+)/; // this checks if the file is, in fact, an image const typeCheck = async (image) => { @@ -39,7 +40,17 @@ module.exports = async (cmdMessage) => { if (type === false) continue; // if the file is an image then return it return type; - // if there's nothing in the attachments check the embeds next + // if there's nothing in the attachments check the urls in the message if there are any + } else if (urlRegex.test(message.content)) { + // get url + const url = message.content.match(urlRegex); + // get type of file + const type = await typeCheck(url[0]); + // move to the next message if the file isn't an image + if (type === false) continue; + // if the file is an image then return it + return type; + // if there's no urls then check the embeds } else if (message.embeds.length !== 0) { // embeds can have 2 possible entries with images, we check the thumbnail first if (message.embeds[0].thumbnail) { diff --git a/utils/pagination/pagination.js b/utils/pagination/pagination.js index a18fc63..675812d 100644 --- a/utils/pagination/pagination.js +++ b/utils/pagination/pagination.js @@ -5,6 +5,7 @@ const client = require("../client.js"); const paginationEmbed = async (message, pages, timeout = 120000) => { const manageMessages = message.channel.guild.members.get(client.user.id).permission.has("manageMessages") || message.channel.permissionsOf(client.user.id).has("manageMessages") ? true : false; let page = 0; + let deleted = false; pages[page].embed.footer.text = `Page ${page + 1} of ${pages.length}`; const currentPage = await message.channel.createMessage(pages[page]); const emojiList = ["◀", "🔢", "▶", "🗑"]; @@ -45,6 +46,7 @@ const paginationEmbed = async (message, pages, timeout = 120000) => { if (manageMessages) msg.removeReaction("▶", userID); break; case "🗑": + deleted = true; reactionCollector.emit("end"); currentPage.delete(); return; @@ -55,7 +57,7 @@ const paginationEmbed = async (message, pages, timeout = 120000) => { }); reactionCollector.once("end", () => { try { - currentPage.removeReactions(); + if (!deleted) currentPage.removeReactions(); } catch (e) { console.log("Reaction message was deleted"); }