better error handling, added chant command
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
const { getAttributeLevels } = require('@dsabot/getAttributeLevels');
|
||||
const Chants = require('../data/Chants.json');
|
||||
|
||||
const Chants = require('../data/Chants');
|
||||
const getChant = ({ Character: Character = [], chant_name: chant_name = '' } = {}) => {
|
||||
let chant_entry =
|
||||
Chants.find(chant => chant.id.toLowerCase() === chant_name.toLowerCase()) ||
|
||||
@ -10,13 +10,13 @@ const getChant = ({ Character: Character = [], chant_name: chant_name = '' } = {
|
||||
console.log(`getChant() Did not find entry for ${chant_name}`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Character.hasOwnProperty('chants')) return;
|
||||
let Level = 0; // This is the minimum attributes value.
|
||||
let Chant = Character.chants.find(chant => chant.id === chant_entry.id) || {};
|
||||
if (Chant && Chant.hasOwnProperty('level')) {
|
||||
Level = Chant.level || 0;
|
||||
}
|
||||
|
||||
console.log(chant_entry);
|
||||
let Attributes = getAttributeLevels(chant_entry.attributes, Character);
|
||||
|
||||
return {
|
||||
|
Reference in New Issue
Block a user