better error handling, added chant command
This commit is contained in:
@ -6,7 +6,7 @@ const { findMessage } = require('@dsabot/findMessage');
|
||||
const { getSpell } = require('@dsabot/getSpell');
|
||||
const { CalculateQuality } = require('@dsabot/CalculateQuality');
|
||||
const { CompareResults } = require('@dsabot/CompareResults');
|
||||
const { CreateResultTable } = require('@dsabot/CreateResultTable');
|
||||
const { CreateResultTable, f } = require('@dsabot/CreateResultTable');
|
||||
module.exports = {
|
||||
name: 'cast',
|
||||
description:
|
||||
@ -15,17 +15,17 @@ module.exports = {
|
||||
' die Berechnung einbezogen.',
|
||||
aliases: ['zaubern'],
|
||||
usage: '<Zaubern> [<-Erschwernis> / <+Erleichterung>]',
|
||||
needs_args: true,
|
||||
needs_args: false,
|
||||
async exec(message, args) {
|
||||
db.find({ user: message.author.tag }, (err, docs) => {
|
||||
if (docs.length === 0) {
|
||||
return message.reply(findMessage('NOENTRY'));
|
||||
}
|
||||
if (!docs[0].character.hasOwnProperty('spells'))
|
||||
return message.reply(findMessage('NO_SPELLS'));
|
||||
if (!isNaN(args[0])) {
|
||||
return message.reply(findMessage('WRONG_ARGUMENTS'));
|
||||
}
|
||||
|
||||
console.log(args[0]);
|
||||
const Spell = getSpell({ Character: docs[0].character, spell_name: args[0] });
|
||||
if (!Spell) {
|
||||
return message.reply(findMessage('SPELL_UNKNOWN'));
|
||||
@ -44,11 +44,14 @@ module.exports = {
|
||||
);
|
||||
const Reply = new Discord.MessageEmbed();
|
||||
Reply.addFields({
|
||||
name: `Du würfelst auf das Talent **${Spell.Name}** (Stufe ${Spell.Level} + ${Bonus})`,
|
||||
name: `Du würfelst auf das Talent **${Spell.Name}** ( Stufe ${Spell.Level} ${
|
||||
Bonus ? `${f(Bonus)} ` : ''
|
||||
})`,
|
||||
value: CreateResultTable({
|
||||
Attributes: Attributes,
|
||||
Throws: DiceThrow,
|
||||
PointsUsed: PointsUsed,
|
||||
Bonus: Bonus,
|
||||
}),
|
||||
inline: false,
|
||||
});
|
||||
@ -69,15 +72,17 @@ module.exports = {
|
||||
} else if (Passed < 3) {
|
||||
Reply.addFields({
|
||||
name: findMessage('TITLE_FAILURE'),
|
||||
value: `${Passed === 0 ? 'Keine Probe' : `nur ${Passed}/3 Proben`} erfolgreich. 😪`,
|
||||
value: `${
|
||||
Passed === 0 ? 'Keine Probe' : `nur ${Passed}/3 Proben`
|
||||
} erfolgreich. 😪`,
|
||||
inline: false,
|
||||
});
|
||||
} else {
|
||||
Reply.addFields({
|
||||
name: findMessage('TITLE_SUCCESS'),
|
||||
value: `Dein verbleibender Bonus: ${PointsRemaining}/${Spell.Level} (QS${CalculateQuality(
|
||||
PointsRemaining
|
||||
)})`,
|
||||
value: `Dein verbleibender Bonus: ${PointsRemaining}/${
|
||||
Spell.Level
|
||||
} (QS${CalculateQuality(PointsRemaining)})`,
|
||||
inline: false,
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user