example01.requestAsync().then(response => { console.log(colors.cyan('Async/Await output: ')); console.log(colors.green(response)); });
/** * Initialize and start the bot. */ function start() { console.log(c.cyan("Carregando eventos...")); loadEvents("./events"); console.log(c.cyan("Carregando comandos...")); loadCommands("./commands"); console.log(c.cyan("Conectando o bot...")); client.login(process.env.CLIENT_TOKEN); client.mongoose.init(); }
info(depth, message, language, additionalGreyMessage){ if (language) { console.log(colors.cyan(this.depth(depth) + message) + colors.grey(additionalGreyMessage || '') + ' ' + colors.yellow(language || '')); } else { console.log(colors.cyan(this.depth(depth) + message) + colors.grey(additionalGreyMessage || '')); } return this; }
function listChapters() { let table = new Table({ head: [colors.cyan('Index'), colors.cyan('Chapter')] }); for (let i = 0; i <= 113; i++) { chapterList.push({ index: (i + 1), name: meta.sura[i].$.tname, ename: meta.sura[i].$.ename, aname: meta.sura[i].$.name, ayas: meta.sura[i].$.ayas, rukus: meta.sura[i].$.rukus, start: meta.sura[i].$.start, type: meta.sura[i].$.type, order: meta.sura[i].$.order }); } chapterList.forEach(function (chapter) { table.push([colors.green(chapter.index), colors.yellow(chapter.name)]); }); print(table.toString()); }
displayHelp() { let stdout = ''; stdout += colors.yellow(('Bunny Builder ' + this.getBuilderVersion())) + "\n"; stdout += "\n"; stdout += 'Commands:\n'; stdout += ("\n"); for (let cmd in this._cmds) { stdout += colors.yellow(` node build ${this._cmds[cmd].name}`); this._cmds[cmd].params.forEach(param => { stdout += colors.magenta(' ' + param); }); stdout += ' - ' + this._cmds[cmd].description + "\n"; } stdout += '\n'; stdout += 'Global arguments:\n'; stdout += '\n'; stdout += colors.cyan(' -p'); stdout += ' - execute JS or CSS command in Production mode to minify assets'; stdout += '\n'; console.info(stdout); }
function getEntireChapter(chapter, arabic) { if (isNaN(chapter)) { print(colors.red('Invalid chapter number.')); process.exit(1); } let table = new Table({ colWidths: [null, 80], wordWrap: true, style: { head: [], border: [] } }); table.push( [{ colSpan: 2, content: colors.green(meta.sura[chapter].$.index + ' : ' + meta.sura[chapter].$.name + ' (' + meta.sura[chapter].$.ename + ')') }] ); table.push( [colors.cyan('Verse'), colors.cyan('Text')] ); table = setVerses(table, chapter, quran[chapter].aya, arabic); print(table.toString()); }
// [INFO] console out var info = function(message) { console.log(colors.cyan('[INFO]'), message); }
example02.errorPromise() .then(error => { console.log(colors.cyan('Promise output: ')); console.log(colors.red(error)) });
example03.conditionalAsync() .then(response => { console.log(colors.cyan('Async/Await output: ')); console.log(colors.green(JSON.stringify(response))); });
const debug = msg => console.log(colors.cyan(msg.toUpperCase()))
example02.errorAsync() .then(error => { console.log(colors.cyan('Async/Await output: ')); console.log(colors.red(error)); });
example03.conditionalPromise() .then(response => { console.log(colors.cyan('Promise output: ')); console.log(colors.green(JSON.stringify(response))); });
example04.intermediateValuesPromise() .then(response => { console.log(colors.cyan('Promise output: ')); console.log(colors.green(response)); });
example04.intermediateValuesAsync() .then(response => { console.log(colors.cyan('Async/Await output: ')); console.log(colors.green(response)); });
example01.requestPromise().then(response => { console.log(colors.cyan('Promise output: ')); console.log(colors.green(response)); });