From dfd033739701dc9a54878730c6fe9fa43fab5af6 Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Sun, 19 Sep 2021 11:39:34 +0300 Subject: [PATCH] diction - filter empty definitions --- diction/plugin.json | 2 +- diction/plugin.ts | 10 ++++++---- squeebot.repo.json | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/diction/plugin.json b/diction/plugin.json index fb3a532..2abf437 100644 --- a/diction/plugin.json +++ b/diction/plugin.json @@ -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": [] diff --git a/diction/plugin.ts b/diction/plugin.ts index 84cc2f4..cd73d09 100644 --- a/diction/plugin.ts +++ b/diction/plugin.ts @@ -160,9 +160,11 @@ class DictionPlugin extends Plugin { lastTime: Date.now(), } ], - definitions: (response as Record[]).map(({ partOfSpeech, text }) => ({ - partOfSpeech, text: text.replace(/(<([^>]+)>)/ig, '') - })), + definitions: (response as Record[]) + .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: '' }); diff --git a/squeebot.repo.json b/squeebot.repo.json index 64c7091..1272954 100644 --- a/squeebot.repo.json +++ b/squeebot.repo.json @@ -11,7 +11,7 @@ }, { "name": "diction", - "version": "1.2.1" + "version": "1.2.2" }, { "name": "fun",