# BlackJack

## &#x20;                                       BlackJack Example -

```javascript
const { blackjack } = require("jelly-djs");
client.on('messageCreate', async(msg) => {
  if(msg.content === '!blackjack'){
        
        let game = blackjack(msg, client)
        
        switch (game.result) {
            
          case 'Win':
            // do win stuff here
            break;
          case 'Tie':
            // do tie stuff here
            break;
          case 'Lose':
            // do lose stuff here
            break;
          case 'Double Win':
            // do double win stuff here
            break;
          case 'Double Lose':
            // do double lose stuff here
            break;
          case 'ERROR':
            // do whatever you want
            break;
            
        }
  } 
})
```

### Required Parameters -

| Parameter - |                          Type                         |                     Description                     |
| ----------- | :---------------------------------------------------: | :-------------------------------------------------: |
| Message     | [Object](https://www.w3schools.com/js/js_objects.asp) |          Message variable used in your code         |
| Client -    | [Object](https://www.w3schools.com/js/js_objects.asp) | Your variable which you used to define your client. |

### Optional Parametres (Must be inside an object) -

{% tabs %}
{% tab title="resultEmbed" %}
Name - `resultEmbed`

Type - `boolean`

Description - *If its set to false then your bot will not send any embeds on results, like if an user wins then it will not send anything. Normally its set to false.*

Required - `false`
{% endtab %}
{% endtabs %}

### Example with options -

```javascript
const game = await blackjack(message, bot, { resultEmbed: false})//it wont send embeds on results.
switch (game.result) {

        case 'Win':
            message.channel.send({embeds: [
                new Discord.MessageEmbed()
                    .setAuthor(usertag, avatar)
                    .setTitle(`You Win!`)
                    .addField(`Your Hand`, `Cards: ${game.ycontent}\nTotal: \`${game.yvalue}\``)
                    .addField(`My Hand Hand`, `Cards: ${game.dcontent}\nTotal: \`${game.dvalue}\``)
                    .setColor('#26f063')
            ]})

            // do win stuff here

            break;
            //Continue with all the cases.
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jelly.js.org/blackjack.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
