mirror of https://github.com/thaldrin/thaldrin.git
begin with roll command
This commit is contained in:
parent
f0cfa0e6fa
commit
6b4a5fb62c
|
@ -79,6 +79,12 @@
|
|||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.37.tgz",
|
||||
"integrity": "sha512-XYmBiy+ohOR4Lh5jE379fV2IU+6Jn4g5qASinhitfyO71b/sCo6MKsMLF5tc7Zf2CE8hViVQyYSobJNke8OvUw=="
|
||||
},
|
||||
"@types/roll": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/roll/-/roll-1.2.0.tgz",
|
||||
"integrity": "sha512-8Khu3DXG3o8GOdbXQbNzWqqa4rAtR0HGw6o37RP4CHgYFjQp3DTSGUpCKt/ujfD+ZRPOxi+ZJIhia7F5cX0pbA==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/websocket": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/websocket/-/websocket-1.0.2.tgz",
|
||||
|
@ -608,6 +614,11 @@
|
|||
"mime-db": "1.46.0"
|
||||
}
|
||||
},
|
||||
"minimist": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
|
||||
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
|
||||
},
|
||||
"moment": {
|
||||
"version": "2.29.1",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
|
||||
|
@ -747,6 +758,14 @@
|
|||
"tough-cookie": "^2.3.3"
|
||||
}
|
||||
},
|
||||
"roll": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/roll/-/roll-1.3.1.tgz",
|
||||
"integrity": "sha512-f6ePWG9fqC5RZE4CqFfxSqfvpOs3sZlxpvtdpNCHPKz76L1oJP8wQzqrMCHpXg8Ahc+53A7RPXMptDUxwciZow==",
|
||||
"requires": {
|
||||
"minimist": "^1.2.5"
|
||||
}
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
"@thaldrin/sourcefinder": "^1.0.3",
|
||||
"chalk": "^4.1.0",
|
||||
"discord.js": "^12.5.3",
|
||||
"roll": "^1.3.1",
|
||||
"trello-helper": "^3.0.7",
|
||||
"winston": "^3.3.3",
|
||||
"winston-daily-rotate-file": "^4.5.1",
|
||||
|
@ -34,6 +35,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.14.37",
|
||||
"@types/roll": "^1.2.0",
|
||||
"@types/ws": "^7.4.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
import Command from "../../handler/structures/Command";
|
||||
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 {
|
||||
constructor() {
|
||||
super({
|
||||
name: "roll",
|
||||
description: "Roll Dice",
|
||||
cooldown: 0,
|
||||
});
|
||||
}
|
||||
|
||||
async command(ctx: Context) {
|
||||
let Dice = ctx.args.join(" ")
|
||||
// @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++
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1 +1 @@
|
|||
Subproject commit 2e14cb549c99cbc7eef68bf294f003e23c46bc5b
|
||||
Subproject commit b9d4df8fc6e4aeaa35911f40a5170bfd146374a0
|
Loading…
Reference in New Issue