diff --git a/classes/imageCommand.js b/classes/imageCommand.js index 922858a..cefe2ba 100644 --- a/classes/imageCommand.js +++ b/classes/imageCommand.js @@ -56,10 +56,12 @@ class ImageCommand extends Command { if (image === undefined) { collections.runningCommands.delete(this.message.author.id); return this.constructor.noImage; - } - if (image.type === "large") { + } else if (image.type === "large") { collections.runningCommands.delete(this.message.author.id); - return `${this.message.author.mention}, that image is too large!`; + return "That image is too large!"; + } else if (image.type === "tenorlimit") { + collections.runningCommands.delete(this.message.author.id); + return "I've been rate-limited by Tenor. Please try uploading the GIF elsewhere."; } magickParams.path = image.path; magickParams.type = image.type; diff --git a/commands/general/channel.js b/commands/general/channel.js index e0b74f8..a44924d 100644 --- a/commands/general/channel.js +++ b/commands/general/channel.js @@ -4,7 +4,7 @@ const Command = require("../../classes/command.js"); class ChannelCommand extends Command { async run() { if (!this.message.channel.guild) return "This command only works in servers!"; - if (!this.message.member.permission.has("administrator") && this.message.member.id !== process.env.OWNER) return "You need to be an administrator to enable/disable me!"; + if (!this.message.member.permissions.has("administrator") && this.message.member.id !== process.env.OWNER) return "You need to be an administrator to enable/disable me!"; if (this.args.length === 0) return "You need to provide whether I should be enabled or disabled in this channel!"; if (this.args[0] !== "disable" && this.args[0] !== "enable") return "That's not a valid option!"; diff --git a/commands/general/prefix.js b/commands/general/prefix.js index 5aaa8c5..19b29c4 100644 --- a/commands/general/prefix.js +++ b/commands/general/prefix.js @@ -6,7 +6,7 @@ class PrefixCommand extends Command { if (!this.message.channel.guild) return "This command only works in servers!"; const guild = await database.getGuild(this.message.channel.guild.id); if (this.args.length !== 0) { - if (!this.message.member.permission.has("administrator") && this.message.member.id !== process.env.OWNER) return "You need to be an administrator to change the bot prefix!"; + if (!this.message.member.permissions.has("administrator") && this.message.member.id !== process.env.OWNER) return "You need to be an administrator to change the bot prefix!"; await database.setPrefix(this.args[0], this.message.channel.guild); return `The prefix has been changed to ${this.args[0]}.`; } else { diff --git a/commands/tags/tags.js b/commands/tags/tags.js index ae2f7f3..6a5ca59 100644 --- a/commands/tags/tags.js +++ b/commands/tags/tags.js @@ -25,13 +25,13 @@ class TagsCommand extends Command { case "remove": if (this.args[1] === undefined) return "You need to provide the name of the tag you want to delete!"; if (!tags[this.args[1].toLowerCase()]) return "This tag doesn't exist!"; - if (tags[this.args[1].toLowerCase()].author !== this.message.author.id && !this.message.member.permission.has("manageMessages") && this.message.author.id !== process.env.OWNER) return "You don't own this tag!"; + if (tags[this.args[1].toLowerCase()].author !== this.message.author.id && !this.message.member.permissions.has("manageMessages") && this.message.author.id !== process.env.OWNER) return "You don't own this tag!"; await database.removeTag(this.args[1].toLowerCase(), this.message.channel.guild); return `The tag \`${this.args[1].toLowerCase()}\` has been deleted!`; case "edit": if (this.args[1] === undefined) return "You need to provide the name of the tag you want to edit!"; if (!tags[this.args[1].toLowerCase()]) return "This tag doesn't exist!"; - if (tags[this.args[1].toLowerCase()].author !== this.message.author.id && !this.message.member.permission.has("manageMessages") && this.message.author.id !== process.env.OWNER) return "You don't own this tag!"; + if (tags[this.args[1].toLowerCase()].author !== this.message.author.id && !this.message.member.permissions.has("manageMessages") && this.message.author.id !== process.env.OWNER) return "You don't own this tag!"; await this.setTag(this.args.slice(2).join(" "), this.args[1].toLowerCase(), this.message, guild); return `The tag \`${this.args[1].toLowerCase()}\` has been edited!`; case "own": @@ -72,7 +72,7 @@ class TagsCommand extends Command { return tags[random(Object.keys(tags))].content; case "enable": case "disable": - if (!this.message.member.permission.has("manageMessages") && this.message.author.id !== process.env.OWNER) return "You don't have permission to disable tags!"; + if (!this.message.member.permissions.has("manageMessages") && this.message.author.id !== process.env.OWNER) return "You don't have permission to disable tags!"; var toggleResult = await database.toggleTags(this.message.channel.guild); return `Tags for this guild have been ${toggleResult ? "disabled" : "enabled"}. To ${toggleResult ? "enable" : "disable"} them again, run ${guild.prefix}tags ${toggleResult ? "enable" : "disable"}.`; default: diff --git a/utils/imagedetect.js b/utils/imagedetect.js index 2dd6e51..1c84b0d 100644 --- a/utils/imagedetect.js +++ b/utils/imagedetect.js @@ -47,7 +47,8 @@ const getImage = async (image, image2, video, gifv = false) => { // so we use that if there's a key in the config and fall back to using the MP4 if there isn't // Note that MP4 conversion requires an ImageMagick build that supports MPEG decoding if (process.env.TENOR !== "") { - const data = await fetch(`https://api.tenor.com/v1/gifs?ids=${image2.split("-").pop()}&key=${process.env.TENOR}`); + const data = await fetch(`https://g.tenor.com/v1/gifs?ids=${image2.split("-").pop()}&media_filter=minimal&limit=1&key=${process.env.TENOR}`); + if (data.status === 429) return "tenorlimit"; const json = await data.json(); payload.path = json.results[0].media[0].gif.url; } else { @@ -106,7 +107,7 @@ const checkImages = async (message, video) => { } else if (message.attachments.length !== 0 && message.attachments[0].width) { type = await getImage(message.attachments[0].proxy_url, message.attachments[0].url, video); } - // if the file is an image then return it + // if the return value exists then return it return type ? type : false; };