diction - filter empty definitions

This commit is contained in:
Evert Prants 2021-09-19 11:39:34 +03:00
parent 2b42fb63f4
commit dfd0337397
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
3 changed files with 8 additions and 6 deletions

View File

@ -2,7 +2,7 @@
"main": "plugin.js",
"name": "diction",
"description": "Find definitions for words",
"version": "1.2.1",
"version": "1.2.2",
"tags": ["commands", "utility", "dictionary"],
"dependencies": ["simplecommands"],
"npmDependencies": []

View File

@ -160,9 +160,11 @@ class DictionPlugin extends Plugin {
lastTime: Date.now(),
}
],
definitions: (response as Record<string, string>[]).map(({ partOfSpeech, text }) => ({
partOfSpeech, text: text.replace(/(<([^>]+)>)/ig, '')
})),
definitions: (response as Record<string, string>[])
.filter(entry => entry.text)
.map(({ partOfSpeech, text }) => ({
partOfSpeech, text: text.replace(/(<([^>]+)>)/ig, '')
})),
inserted: Date.now(),
}
@ -182,7 +184,7 @@ class DictionPlugin extends Plugin {
return true;
},
match: /define (\w*)/,
aliases: ['df'],
aliases: ['df', 'word'],
description: 'Find definitions for words. Call again to advance to next definition',
usage: '<word>'
});

View File

@ -11,7 +11,7 @@
},
{
"name": "diction",
"version": "1.2.1"
"version": "1.2.2"
},
{
"name": "fun",