Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const results = [];
- for (let i = 0; i < data.results.length; i++) {
- const result = data.results[i];
- const item = {
- result: [],
- pronunciations: [],
- };
- for (let j = 0; j < result.lexicalEntries.length; j++) {
- const lexicalEntry = result.lexicalEntries[j];
- for (let k = 0; k < lexicalEntry.entries.length; k++) {
- const entry = lexicalEntry.entries[k];
- for (let m = 0; m < entry.senses.length; m++) {
- const sense = entry.senses[m];
- const defExa = { definitions: [], examples: [] };
- if(useSearch === false) {
- for (let n = 0; n < sense.definitions.length; n++) {
- const definition = sense.definitions[n];
- defExa.definitions.push(definition);
- //console.log(definition);
- }
- } else {
- if(sense.hasOwnProperty('examples')) {
- for (let n = 0; n < sense.examples.length; n++) {
- const example = sense.examples[n];
- defExa.examples.push(example.text);
- //console.log(examples);
- }
- }
- }
- item.result.push(defExa);
- }
- }
- for (let k = 0; k < lexicalEntry.pronunciations.length; k++) {
- const pronunciation = lexicalEntry.pronunciations[k];
- item.pronunciations.push(pronunciation.audioFile);
- //console.log(pronunciation.audioFile);
- }
- }
- results.push(item);
- }
- //console.log(results);
- const displaySet = [];
- let displayText = query + ': ';
- let hasDefinitions = false;
- let hasExamples = false;
- for (let i = 0; i < results.length; i++) {
- const item = results[i];
- for (let j = 0; j < item.result.length; j++) {
- const result = item.result[j];
- hasDefinitions = result.definitions.length > 0;
- hasExamples = result.examples.length > 0;
- const text = '(' + (hasDefinitions ? result.definitions.join(' | ') : '') + (hasExamples ? result.examples.join(' | ') : '') + ')';
- displayText += text;
- if(displayText.length < 500) {
- displaySet.push(text);
- }
- }
- }
- if(hasDefinitions === true || hasExamples === true) {
- chatCommand.sendNotice(irc, event, `@${event.data.user.username} ${query}: ${displaySet.join(',')}`);
- }
- else {
- chatCommand.sendNotice(irc, event, `@${event.data.user.username} ${query}: Has no results.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement