@@ -12,7 +12,7 @@ const maintainerID = '274434863711518722';
12
12
13
13
const request = require ( 'request-promise-native' ) ;
14
14
15
- const maxRelatedTopics = 3 ;
15
+ const maxRelatedTopics = 4 ;
16
16
17
17
/*
18
18
------------ HELPER FUNCTIONS ------------
@@ -175,9 +175,11 @@ const wikipediaOpenSearch = async (message, args) => {
175
175
// remove useless definition at index 0:
176
176
definitions . shift ( ) ;
177
177
// collect related definition:
178
- for ( let d of definitions ) {
179
- result += `${ definitions . indexOf ( d ) + 1 } . ${ d } \n\n` ;
180
- if ( definitions . indexOf ( d ) === maxRelatedTopics - 1 ) break ;
178
+ let nonEmptyDefinitions = [ ] ;
179
+ for ( let d of definitions ) if ( d . length > 0 ) nonEmptyDefinitions . push ( d ) ;
180
+ for ( let i = 0 ; i < maxRelatedTopics ; ++ i ) {
181
+ if ( nonEmptyDefinitions [ i ] == undefined ) break ;
182
+ result += `${ i + 1 } . ${ nonEmptyDefinitions [ i ] } \n\n` ;
181
183
}
182
184
result += '```' ;
183
185
} // exact meaning is obtained:
@@ -192,7 +194,9 @@ const wikipediaOpenSearch = async (message, args) => {
192
194
* •• HELP COMMAND ••
193
195
*/
194
196
const showHelp = ( message , args ) => {
195
- sendMessage ( message , `
197
+ sendMessage (
198
+ message ,
199
+ `
196
200
\`\`\`
197
201
NAME
198
202
define -- provide definition for words from web.
@@ -226,7 +230,8 @@ GUIDE
226
230
events, news etc. and does not provide meaning of the words from
227
231
english dictionary. DDG bang redirects will also not work here.
228
232
\`\`\`
229
- ` ) ;
233
+ `
234
+ ) ;
230
235
} ;
231
236
232
237
// run function for !define command:
0 commit comments