easy-api.ts
Version:
A powerful library to create your own API with ease.
1 lines • 1.07 kB
JavaScript
Object.defineProperty(exports,"__esModule",{value:!0});let tslib_1=require("tslib"),APIFunction_1=require("../../classes/structures/APIFunction"),Error_1=require("../../classes/structures/Error"),createCanvas_1=tslib_1.__importDefault(require("./createCanvas")),fs_1=require("fs");class DownloadImage extends APIFunction_1.APIFunction{name="$downloadImage";description="Downloads a cached image into your file system.";parameters=[{name:"Image ID",description:"Cached image ID to be downloaded.",type:APIFunction_1.ParamType.String,required:!0,rest:!1,defaultValue:null},{name:"Path",description:"File path to download the image to.",type:APIFunction_1.ParamType.String,required:!0,rest:!1,defaultValue:null}];usage="$downloadImage[id;path]";returns=APIFunction_1.ParamType.Unknown;aliases=[];compile=!0;parent=new createCanvas_1.default;async run(e,[a,r]){if(!(a=e.parent.getInternalVar("NodeJS.Images:"+a))||!Object.prototype.hasOwnProperty.call(a,"src"))throw new Error_1.InvalidField("Image ID",e.function);(0,fs_1.writeFileSync)(r,a.src)}}exports.default=DownloadImage;