# dsc-utils | Documentation

Welcome 👋\ <br>

### Contact

[Discord Profile](https://discord.com/users/681424352599736327)\
[Discord Server](https://discord.gg/CpHuTqeuyP)\
[E-Mail](mailto:contact@flamex.dev)\
[GitHub](https://github.com/flamexdev/dsc-utils)

### Example

Here you have an example to create these components

<div align="left"><img src="https://user-images.githubusercontent.com/68353308/126049700-72934815-9d78-4cee-8a95-f6b0f8e50ad7.png" alt=""></div>

```javascript
const { Client } = require("discord.js")
const client = new Client()

const Utils = require("dsc-utils")
const utils = new Utils(client)

const token = "Your discord bot token" // https://discord.com/developers/applications

// Execute once the bot is logged in
client.on("ready", async () => {
    console.log(client.user.tag)

    // Create the command
    const cmd = new utils.Command({
        name: "welcome",
        description: "Build a embed",
        default_permission: true
    })

    // Create the options
    const feeling = new utils.Option({
        name: "feeling",
        description: "How do you feel today",
        type: "string"
    })
    // Add choices
    feeling.setChoices([
        new utils.Choice({
            name: "Good",
            value: "good"
        }),
        new utils.Choice({
            name: "It's okay",
            value: "okay"
        }),
        new utils.Choice({
            name: "Not good",
            value: "bad"
        })
    ])

    // Create one more option to test the ephemeral messages
    const ephemeral = new utils.Option({
        name: "ephemeral",
        description: "Set the response to an ephemeral message",
        type: "boolean"
    })

    // Add the options to the command
    cmd.setOptions([
        feeling,
        ephemeral
    ])

    // Create the global command
    console.log(await utils.global().createCommand(cmd))

    /** 
     * Discord is caching all global slash commands for 1 hour but to test the slash command immediately you need create a guild command:
     * 
     * utils.guild("your guild id").createCommand(cmd)
     */
})


// Run once a slash command got executed
client.on("commandExecuted", cmd => {
    console.log(cmd)

    // Create a button
    const button = new utils.Button({
        label: "You're right",
        style: "green",
        ID: "my_id"
    })

    // Response to the interaction with the button
    cmd.callback.post({
        content: `You said you're feeling **${cmd.args.find(e => e.name == "feeling").value}**`,
        components: [button],
        ephemeral: cmd.args.find(e => e.name == "ephemeral").value
    })
})


// Execute once a button got clicked
client.on("buttonClicked", btn => {
    console.log(btn)

    // Response to the button with a dropdown menu
    btn.callback.post({
        content: "Last component :)",
        components: [
            new utils.Dropdown({
                placeholder: "Placeholder",
                min: 0,
                max: 3,
                options: [
                    new utils.DropdownOption({
                        label: "Label 1",
                        value: "Value 1",
                        description: "Description"
                    }),
                    new utils.DropdownOption({
                        label: "Label 2",
                        value: "Value 2",
                        description: "Description",
                        default: true
                    }),
                    new utils.DropdownOption({
                        label: "Label 3",
                        value: "Value 3",
                        description: "Description"
                    })
                ],
                ID: "lel"
            })
        ]
    })
})

client.on("dropdown", dropdown => {
    console.log(dropdown)

    // Response to the dropdown selection with the selected value
    dropdown.callback.post(`You selected ${dropdown.values.map(e => `\`${e}\``).join(" ")}`)
})

client.login(token)
```


---

# 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://flamex.gitbook.io/dsc-utils/master.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.
