Skip to content

Commit cf254a5

Browse files
committed
Create coinFlipCommand.js
1 parent 6e7e6fc commit cf254a5

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const minecraftCommand = require("../../contracts/minecraftCommand.js");
2+
3+
class CoinFlipCommand extends minecraftCommand {
4+
constructor(minecraft) {
5+
super(minecraft);
6+
7+
this.name = "coinflip";
8+
this.aliases = ["coin"];
9+
this.description = "Flips a coin.";
10+
this.options = [];
11+
}
12+
13+
async onCommand(username, message) {
14+
try {
15+
const randNum = Math.random();
16+
17+
if(randNum < .5){
18+
this.send("/gc Heads!");
19+
} else {
20+
this.send("/gc Tails!");
21+
}
22+
} catch (error) {
23+
this.send(`/gc [ERROR] ${error ?? "Something went wrong.."}`);
24+
}
25+
}
26+
}
27+
28+
module.exports = CoinFlipCommand;

0 commit comments

Comments
 (0)