UNPKG

easy-api.ts

Version:

A powerful library to create your own API with ease.

1 lines 1.07 kB
Object.defineProperty(exports,"__esModule",{value:!0});let tslib_1=require("tslib"),APIFunction_1=require("../../classes/structures/APIFunction"),stmt_1=tslib_1.__importDefault(require("../core/stmt")),Error_1=require("../../classes/structures/Error");class Else extends APIFunction_1.APIFunction{name="$else";description="else statement.";parameters=[{name:"Code",description:"Code to execute if the past conditions are not met.",type:APIFunction_1.ParamType.String,required:!0,rest:!1,defaultValue:null}];usage="$else[code]";returns=APIFunction_1.ParamType.Unknown;compile=!1;aliases=[];parent=new stmt_1.default;async run(e,[t]){var r=(e=e.getInternalVar("eats:if_statement"))[0];if(0===e.length)throw new Error_1.EATS_Error("Invalid statement, you must place an $if at start.");if(!/\$if/gi.test(r.name))throw new Error_1.EATS_Error("Invalid statement, you must place an $if at start.");if(e.some(e=>"$else"===e.name))throw new Error_1.EATS_Error("An statement cannot receive more than 1 $else.");e.push({name:"$else",condition:null,code:t})}}exports.default=Else;