easy-api.ts
Version:
A powerful library to create your own API with ease.
1 lines • 1.04 kB
JavaScript
Object.defineProperty(exports,"__esModule",{value:!0});let Error_1=require("../../classes/structures/Error"),APIFunction_1=require("../../classes/structures/APIFunction"),fs_1=require("fs");class BufferSave extends APIFunction_1.APIFunction{name="$bufferSave";description="Save the requested buffer into your file system.";parameters=[{name:"Name",description:"The name of the array.",type:APIFunction_1.ParamType.String,required:!0,rest:!1,defaultValue:null},{name:"Path",description:"Path to save the file to, must include extension.",type:APIFunction_1.ParamType.String,required:!0,rest:!1,defaultValue:null}];usage="$bufferSave[name;path (with file extension)]";returns=APIFunction_1.ParamType.Unknown;aliases=[];compile=!0;async run(e,[r,t]){if(!e.internalVarExists("NodeJS.Buffers:"+r))throw new Error_1.InvalidVariableName(Error_1.VariableType.Internal,r,e.function);e=e.getInternalVar("NodeJS.Buffers:"+r);try{(0,fs_1.writeFileSync)(t,e)}catch(e){console.log("Cannot save the provided buffer.\n"+e)}}}exports.default=BufferSave;