mrmBot-Matrix/commands/message/select-image.js

24 lines
1,002 B
JavaScript
Raw Normal View History

2023-03-15 14:09:09 +00:00
import Command from "../../classes/command.js";
import imageDetect from "../../utils/imagedetect.js";
import { selectedImages } from "../../utils/collections.js";
class SelectImageCommand extends Command {
2023-03-19 05:10:48 +00:00
static category = "general"
2023-03-15 14:09:09 +00:00
async run() {
2023-03-17 00:23:01 +00:00
// await this.acknowledge();
2023-03-15 14:09:09 +00:00
const message = this.interaction.data.target;
const image = await imageDetect(this.client, message, this.interaction, this.options, true, false, false, true);
this.success = false;
if (image === undefined) {
return "I couldn't find an image in that message!";
} else if (image.type === "large") {
return "That image is too large (>= 25MB)! Try using a smaller image.";
} else if (image.type === "tenorlimit") {
return "I've been rate-limited by Tenor. Please try uploading your GIF elsewhere.";
}
2023-03-15 14:12:35 +00:00
selectedImages.set(this.author, image);
2023-03-15 14:09:09 +00:00
return "The image has been selected for your next command.";
}
}
export default SelectImageCommand;