Changed Tenor API url, account for ratelimits, switch Member#permission to Member#permissions
This commit is contained in:
parent
e6e1ca61d3
commit
787eb347f6
5 changed files with 13 additions and 10 deletions
|
@ -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;
|
||||
|
|
|
@ -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!";
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue