UNPKG

@kamkam1_0/discord.js

Version:

Allows you to fully interact with discord's apis

33 lines (27 loc) 1.07 kB
const base = require("../bases/components/base") const textInput = require("./textinput") class Form extends base{ constructor(data={}){ super(data) this.title = data.title || null this.components = data.components ? data.components.map(component => new textInput(component)) : [] } AddTextInput(obj){ if(!(obj instanceof textInput) && (typeof obj !== "object" || typeof obj.type !== "number" || !Array.isArray(obj.components) || !obj.components.length)) return this if(obj instanceof textInput) this.components.push({type: 1, components: [obj]}) else this.components.push(obj) return this } AddTextInputs(array){ if(!Array.isArray(array)) array = undefined let texts = array || [...arguments] texts.forEach(e => this.AddTextInput(e)) return this } setTitle(texte){ if(!texte || !isNaN(texte) || texte.length < 1 || texte.length > 75) return this else this.title = texte return this } } module.exports = Form