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", "main": "plugin.js",
"name": "diction", "name": "diction",
"description": "Find definitions for words", "description": "Find definitions for words",
"version": "1.2.1", "version": "1.2.2",
"tags": ["commands", "utility", "dictionary"], "tags": ["commands", "utility", "dictionary"],
"dependencies": ["simplecommands"], "dependencies": ["simplecommands"],
"npmDependencies": [] "npmDependencies": []

View File

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

View File

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