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;
} 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;
}

View File

@ -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}";

View File

@ -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) {

View File

@ -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");
}