thaldrin/src/discord/commands/misc/roll.ts

29 lines
852 B
TypeScript
Raw Normal View History

2021-09-11 11:36:51 +00:00
import { Command } from '@thaldrin/eu';
import { Context } from "../../../utils/types";
import language from "../../../utils/language";
import replace from "../../../utils/replace";
2021-05-05 16:38:19 +00:00
import Roll from 'roll'
const roll = new Roll()
export = class Roll extends Command {
constructor() {
super({
name: "roll",
description: "Roll Dice",
2021-05-05 23:19:03 +00:00
cooldown: 1,
usage: "`amount`**d**`sides` `+-/*x`"
2021-05-05 16:38:19 +00:00
});
}
async command(ctx: Context) {
2021-05-05 23:19:03 +00:00
let Dice: string = ctx.args[0]
let diceThrow = roll.roll(Dice)
2021-05-05 16:38:19 +00:00
// @ts-ignore
2021-07-09 17:52:25 +00:00
let RollMessage = await ctx.channel.send(`${replace(/AMOUNT/gi, diceThrow.input.quantity, replace(/DICE/gi, `d${diceThrow.input.sides}`, language.get(ctx.settings.locale).misc.roll))}`);
2021-05-05 23:19:03 +00:00
await RollMessage.edit(`:game_die: **Results**
Throws: **${diceThrow.rolled.join("**, **")}**
Total: **${diceThrow.result}**`)
2021-05-05 16:38:19 +00:00
}
};