commit c3d21c6676d615a89fcea063f8bea89ef05e68ac
parent 04c1905b83d602f7a578977b3067923b649c5e25
Author: Demonstrandum <moi@knutsen.co>
Date: Sat, 16 May 2020 19:00:14 +0100
SPARSE. ARRAYS.
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/commands/listen.ts b/lib/commands/listen.ts
@@ -12,7 +12,7 @@ export default (home_scope: HomeScope) => {
+ " be either `respond`, `reject`, `replace` or `trigger`"
+ "\nSee `help` page for `listen` for more information.");
- const index_str = args[1]?.trim();
+ const index_str = args[1] || "";
const index = Number(index_str[0] === '#'
? index_str.tail()
: index_str);
@@ -22,7 +22,7 @@ export default (home_scope: HomeScope) => {
+ " (greater than zero), that represents the index of the rule");
const rule_no = CONFIG.rules[rule_type].length;
- if (index > rule_no)
+ if (index > rule_no || CONFIG.rules[rule_type][index - 1] === undefined)
return message.answer(`Index (${index}) is out of range.\n`
+ `Only ${rule_no} elements exist in ${rule_type} rules.`);