Add Skillchecks for Magical Talents (#25)
* initial implementation of spells * added return list of spells. Moved them into seperate json * added _some_ chants, restructuring data from spells * added more chants, added command for getting info * added related messages, added skillcheck for spells (cast) * better error handling, added chant command * (fix) Chants were referring to spells * cleanup testing variables and code * updated README * fixed storage location issues and minor bugs * removed db storage location * rc1 * (fix) chants_title * (fix) Uncaught ReferenceError: Discord is not defined * (fix) more reference errors Co-authored-by: Marcus Netz <marcus.netz@godyo.com>
This commit is contained in:
61
commands/Chants.js
Normal file
61
commands/Chants.js
Normal file
@ -0,0 +1,61 @@
|
||||
//const globals = require('../globals');
|
||||
const globals = require('../globals');
|
||||
const Discord = require('discord.js');
|
||||
const db = globals.db;
|
||||
const { findMessage } = require('@dsabot/findMessage');
|
||||
const { getChant } = require('@dsabot/getChant');
|
||||
module.exports = {
|
||||
name: 'chants',
|
||||
description: 'Zeigt dir deinen Fertigkeitswert im jeweiligen Magietalent (Götterwirken).',
|
||||
aliases: ['segen', 'liturgie', 'liturgien', 'zeremonien'],
|
||||
usage: '[<Liturgie / Zeremonie>]',
|
||||
needs_args: false,
|
||||
|
||||
async exec(message, args) {
|
||||
db.find({ user: message.author.tag }, (err, docs) => {
|
||||
if (docs.length === 0) {
|
||||
return message.reply(findMessage('NOENTRY'));
|
||||
}
|
||||
Character = docs[0].character;
|
||||
if (!Character.hasOwnProperty('chants')) return message.reply(findMessage('NO_CHANTS'));
|
||||
if (args.length === 0) {
|
||||
const Embed = new Discord.MessageEmbed()
|
||||
.setColor('#0099ff')
|
||||
.setTitle(findMessage('CHANTS_TITLE'))
|
||||
.setDescription(findMessage('CHANTS_DESCRIPTION'))
|
||||
.addField(ReplyChantList(createChantList(Character)), '\u200B', true);
|
||||
return message.reply(Embed);
|
||||
}
|
||||
const Chant = getChant({
|
||||
Character: Character,
|
||||
chant_name: args[0],
|
||||
});
|
||||
if (!Chant) {
|
||||
return message.reply(findMessage('SPELL_UNKNOWN'));
|
||||
}
|
||||
return message.reply(ReplyChant(Chant));
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const createChantList = (Character = {}) => {
|
||||
if (!Character || !Character.hasOwnProperty('chants')) return;
|
||||
let ChantList = [];
|
||||
|
||||
// todo: send 'chant' to getChant() so we can filter out blessings.
|
||||
Character.chants.forEach(chant => ChantList.push(getChant({ Character: Character, chant_name: chant.id })));
|
||||
return ChantList.filter(value => value !== undefined);
|
||||
};
|
||||
|
||||
const ReplyChantList = (ChantList = []) => {
|
||||
if (!ChantList) return;
|
||||
return `${ChantList.map(chant => `${chant.Name} ${chant.Level ? `(${chant.Level})` : ''}`).join('\n')}`;
|
||||
};
|
||||
|
||||
const ReplyChant = (Chant = {}) => {
|
||||
if (!Chant) return;
|
||||
return `Deine Werte für ${Chant.Name} ${Chant.Level ? '(' + Chant.Level + ')' : ''} sind:
|
||||
|
||||
${Chant.Attributes.map(attribute => `${attribute.Name}: ${attribute.Level}`).join(' ')}
|
||||
`;
|
||||
};
|
Reference in New Issue
Block a user