mirror of https://github.com/thaldrin/thaldrin.git
finish roll command
This commit is contained in:
parent
6b4a5fb62c
commit
6dda6b779f
File diff suppressed because it is too large
Load Diff
|
@ -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}**`)
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue