Discord Blackjack
Discord Blackjack

discord-blackjack

Blackjack games to be played on Discord!

Easy setup and use

Installation

1
$ npm i discord-blackjack
Copied!

Setup

1
const Discord = require("discord.js");
2
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] });
3
const blackjack = require("discord-blackjack");
4
const prefix = "-";
5
const token = "SOME_TOKEN_HERE";
6
7
client.on("ready", () => {
8
console.log("Bot is online!");
9
})
10
11
client.on("messageCreate", async messages => {
12
13
if (message.author.bot || !message.guild || !message.content.startsWith(prefix)) return;
14
15
if (message.content.startsWith(`${prefix}blackjack`) || message.content.startsWith(`${prefix}bj`)) {
16
17
let game = await blackjack(message, Discord)
18
19
switch (game.result) {
20
21
case 'Win':
22
// do win stuff here
23
break;
24
case 'Tie':
25
// do tie stuff here
26
break;
27
case 'Lose':
28
// do lose stuff here
29
break;
30
case 'Double Win':
31
// do double win stuff here
32
break;
33
case 'Double Lose':
34
// do double lose stuff here
35
break;
36
case 'ERROR':
37
// do whatever you want
38
break;
39
}
40
41
}
42
43
})
Copied!
Check the next topic to see how the code would look like in a command handler!
Last modified 1mo ago