easy-api.ts
Version:
A powerful library to create your own API with ease.
1 lines • 1 kB
JavaScript
Object.defineProperty(exports,"__esModule",{value:!0});let APIFunction_1=require("../../classes/structures/APIFunction"),Error_1=require("../../classes/structures/Error"),Util_1=require("../../classes/internal/Util"),POSSIBLE_CHARS="abcdefghijklmnñopqrstuvwxyz".split("");POSSIBLE_CHARS.push(...POSSIBLE_CHARS.map(e=>e.toUpperCase())),POSSIBLE_CHARS.push(..."1234567890".split(""));class RandomString extends APIFunction_1.APIFunction{name="$randomString";description="Generates a random string.";parameters=[{name:"Length",description:"The length for the text to be generated.",type:APIFunction_1.ParamType.String,required:!1,rest:!1,defaultValue:"5"}];usage="$randomString[length?]";returns=APIFunction_1.ParamType.String;aliases=[];compile=!0;async run(e,[r="5"]){if(!Util_1.Util.isNumber(r))throw new Error_1.InvalidFieldIndex(r,e.function,"String Length");let t="";for(let e=0;e<Number(r);e++)t+=POSSIBLE_CHARS[Math.floor(Math.random()*POSSIBLE_CHARS.length)];return t}}exports.default=RandomString;