UNPKG

easy-api.ts

Version:

A powerful library to create your own API with ease.

1 lines 1.11 kB
Object.defineProperty(exports,"__esModule",{value:!0});let APIFunction_1=require("../../classes/structures/APIFunction"),Error_1=require("../../classes/structures/Error");class StringAt extends APIFunction_1.APIFunction{name="$stringAt";description="Retrieves the character at the provided index.";parameters=[{name:"Text",description:"The text to work with.",type:APIFunction_1.ParamType.String,required:!0,rest:!1,defaultValue:null},{name:"Index",description:"Character index to get from the text.",type:APIFunction_1.ParamType.Number,required:!0,rest:!1,defaultValue:null}];usage="$stringAt[text;index]";returns=APIFunction_1.ParamType.String;aliases=["$charAt"];compile=!0;async run(e){var[r,t]=await this.resolveTypedFields();if(isNaN(t))throw new Error_1.EATS_Error("Index must be a valid number at: "+e.function?.name);if(t<1)throw new Error_1.EATS_Error("Index must be a valid number greater than 0 at: "+e.function?.name);if(t>r.length)throw new Error_1.EATS_Error(`Index must be a valid number lower o equal than ${r.length} at: `+e.function?.name);return r.charAt(t-1)}}exports.default=StringAt;