finish roll command

This commit is contained in:
Lio Young 2021-05-06 01:19:03 +02:00
parent 6b4a5fb62c
commit 6dda6b779f
No known key found for this signature in database
GPG Key ID: 789795A11879E169
2 changed files with 1234 additions and 14 deletions

1226
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -3,8 +3,6 @@ import { Context } from "../../utils/types";
import lingua from "../../utils/lingua";
import replace from "../../utils/replace";
import Roll from 'roll'
const DiceRegex = /^(?<amount>\d*)d(?<die>\d*)/
const roll = new Roll()
export = class Roll extends Command {
@ -12,21 +10,19 @@ export = class Roll extends Command {
super({
name: "roll",
description: "Roll Dice",
cooldown: 0,
cooldown: 1,
usage: "`amount`**d**`sides` `+-/*x`"
});
}
async command(ctx: Context) {
let Dice = ctx.args.join(" ")
let Dice: string = ctx.args[0]
let diceThrow = roll.roll(Dice)
// @ts-ignore
let { amount, die } = Dice.match(DiceRegex)?.groups
let total = 0
// @ts-ignore
let RollMessage = await ctx.channel.send(`${replace(/AMOUNT/gi, 1, replace(/DICE/gi, "d20", lingua[ctx.settings.locale].ROLL))}`);
while (total <= amount) {
// @ts-ignore
await RollMessage.edit(RollMessage.content += replace(/RESULT/gi, 1, replace(/CURRENT/gi, total, replace(/AMOUNT/gi, amount, lingua[ctx.settings.locale].ROLL_MSG))))
total++
}
let RollMessage = await ctx.channel.send(`${replace(/AMOUNT/gi, diceThrow.input.quantity, replace(/DICE/gi, `d${diceThrow.input.sides}`, lingua[ctx.settings.locale].ROLL))}`);
await RollMessage.edit(`:game_die: **Results**
Throws: **${diceThrow.rolled.join("**, **")}**
Total: **${diceThrow.result}**`)
}
};