discord-coc-bot
Version:
A Discord bot that contains commands useful for Call of Cthulu text roleplaying, based on RPbot by Gawdl3y (https://github.com/Gawdl3y/discord-rpbot/)
30 lines (26 loc) • 876 B
JavaScript
'use babel';
;
import { Command, CommandFormatError } from 'discord-graf';
import DiceExpression from 'dice-expression-evaluator';
export default class MaxRollCommand extends Command {
constructor(bot) {
super(bot, {
name: 'max-roll',
module: 'dice',
memberName: 'max',
description: 'Calculates the maximum possible roll for a dice expression.',
usage: 'max-roll <dice expression>',
details: 'The dice expression follows the same rules as !roll, but targets (< or >) cannot be used.',
examples: ['max-roll 2d20', 'max-roll 3d20 - d10 + 6']
});
}
async run(message, args) {
if(!args[0]) throw new CommandFormatError(this, message.guild);
try {
const maxRoll = new DiceExpression(args[0]).max();
return `The maximum possible roll is **${maxRoll}**.`;
} catch(err) {
return 'Invalid dice expression specified.';
}
}
}