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