Added name input to avatar, added alias for help, other changes

This commit is contained in:
TheEssem 2019-12-09 15:33:06 -06:00
parent 7eb9bfeef4
commit c1f2eadf88
4 changed files with 22 additions and 2 deletions

View File

@ -5,6 +5,12 @@ exports.run = async (message, args) => {
return message.mentions[0].avatarURL; return message.mentions[0].avatarURL;
} else if (client.users.get(args[0]) !== undefined) { } else if (client.users.get(args[0]) !== undefined) {
return client.users.get(args[0]).avatarURL; 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 { } else {
return message.author.avatarURL; return message.author.avatarURL;
} }

View File

@ -105,6 +105,7 @@ exports.run = async (message, args) => {
} }
}; };
exports.aliases = ["commands"];
exports.category = 1; exports.category = 1;
exports.help = "Gets a list of commands"; exports.help = "Gets a list of commands";
exports.params = "{command}"; exports.params = "{command}";

View File

@ -1,5 +1,6 @@
const fetch = require("node-fetch"); const fetch = require("node-fetch");
const fileType = require("file-type"); const fileType = require("file-type");
const urlRegex = /(?:\w+:)?\/\/(\S+)/;
// this checks if the file is, in fact, an image // this checks if the file is, in fact, an image
const typeCheck = async (image) => { const typeCheck = async (image) => {
@ -39,7 +40,17 @@ module.exports = async (cmdMessage) => {
if (type === false) continue; if (type === false) continue;
// if the file is an image then return it // if the file is an image then return it
return type; 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) { } else if (message.embeds.length !== 0) {
// embeds can have 2 possible entries with images, we check the thumbnail first // embeds can have 2 possible entries with images, we check the thumbnail first
if (message.embeds[0].thumbnail) { if (message.embeds[0].thumbnail) {

View File

@ -5,6 +5,7 @@ const client = require("../client.js");
const paginationEmbed = async (message, pages, timeout = 120000) => { 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; 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 page = 0;
let deleted = false;
pages[page].embed.footer.text = `Page ${page + 1} of ${pages.length}`; pages[page].embed.footer.text = `Page ${page + 1} of ${pages.length}`;
const currentPage = await message.channel.createMessage(pages[page]); const currentPage = await message.channel.createMessage(pages[page]);
const emojiList = ["◀", "🔢", "▶", "🗑"]; const emojiList = ["◀", "🔢", "▶", "🗑"];
@ -45,6 +46,7 @@ const paginationEmbed = async (message, pages, timeout = 120000) => {
if (manageMessages) msg.removeReaction("▶", userID); if (manageMessages) msg.removeReaction("▶", userID);
break; break;
case "🗑": case "🗑":
deleted = true;
reactionCollector.emit("end"); reactionCollector.emit("end");
currentPage.delete(); currentPage.delete();
return; return;
@ -55,7 +57,7 @@ const paginationEmbed = async (message, pages, timeout = 120000) => {
}); });
reactionCollector.once("end", () => { reactionCollector.once("end", () => {
try { try {
currentPage.removeReactions(); if (!deleted) currentPage.removeReactions();
} catch (e) { } catch (e) {
console.log("Reaction message was deleted"); console.log("Reaction message was deleted");
} }