easy-api.ts
Version:
A powerful library to create your own API with ease.
1 lines • 1.08 kB
JavaScript
Object.defineProperty(exports,"__esModule",{value:!0});let APIFunction_1=require("../../classes/structures/APIFunction"),Util_1=require("../../classes/internal/Util");class Try extends APIFunction_1.APIFunction{name="$try";description="Try to execute the given code, if something goes wrong, catch code is executed.";parameters=[{name:"Code",description:"Code to be executed.",type:APIFunction_1.ParamType.String,required:!0,rest:!1,defaultValue:null},{name:"Catch Code",description:"Code to be executed in case some error ocurrs.",type:APIFunction_1.ParamType.String,required:!0,rest:!1,defaultValue:null},{name:"Finally Code",description:"Code to be executed finally.",type:APIFunction_1.ParamType.String,required:!1,rest:!1,defaultValue:null}];usage="$try[code;catch;finally?]";returns=APIFunction_1.ParamType.Unknown;compile=!1;aliases=[];async run(e,[t,r,i]){let n;try{n=await Util_1.Util.resolveCode(e,t)}catch(t){r=r.replace(/%ERROR%/gi,t.message),n=await Util_1.Util.resolveCode(e,r)}finally{void 0!==i&&(n=await Util_1.Util.resolveCode(e,i))}return n}}exports.default=Try;