# Getting Started

### Installation <a href="#installation" id="installation"></a>

&#x20;**วิธีการติดตั้งโมดูล LavaOne (NPM)**

{% code title="Install LavaOne" %}

```scala
npm install lavaone -s
```

{% endcode %}

### How to use the module

#### &#x20;**วิธีใช้การโมดูล LavaOne**

```javascript
const lavaone = require("lavaone");
const discord = require("discord.js");

let client = new discord.Client();

let nodes = [
    {
      host: "127.0.0.1",
      port: 2333,
      password: "iqcodeiq",
    }
]

client.on("ready", async () => {
  client.music = new lavaone.LavaClient(client, nodes);
  
  client.music.Spotify = new lavaone.Spotify(
      "Spotify Client ID",
      "Spotify Client Scret"
   );

  client.music.on("nodeSuccess", (node) => {
    console.log(`Node connected: ${node.options.host}`);
  });

  client.music.on("nodeError", console.error);
});

client.login("Token");
```

#### &#x20;**วิธีใช้การค้นหาเพลงจาก youtube**

```javascript
client.on("message", async (message) => {
  console.log(message.content);
  let prefix = "!";
  var slice = message.content.startsWith(prefix) ? prefix.length : 0;
  const args = message.content.slice(slice).split(/\s+/);
  var command = args.shift().toLowerCase();
  if (command == "play") {
    let voiceChannel = message.member.voice.channel;
    if (!voiceChannel) return message.channel.send("คุณไม่ได้อยู่ในห้องคุย");

    let player = await client.music.spawnPlayer(
      {
        guild: message.guild,
        voiceChannel, // ห้องเสียงที่ต้องการเล่นเพลง
        textChannel: message.channel, // ห้องข้อความ
        volume: 100, // ระดับเสียงเพลง
        deafen: true, // ปิดหูฟัง
      },
      {
        skipOnError: true,
      }
    );
    var res;
    try {
      res = await player.lavaSearch(args.slice(0).join(" "), message.member, {
        source: "yt",
        add: false,
      });
    } catch (e) {
      if (e) return await message.channel.send("Error ไม่สามารถหาเพลงได้");
    }

    player.queue.add(res[0]);
    if (!player.playing) await player.play();
  }
  if (command == "skip") {
    let voiceChannel = message.member.voice.channel;
    if (!voiceChannel) return message.channel.send("คุณไม่ได้อยู่ในห้องคุย");

    let player = await client.music.spawnPlayer(
      {
        guild: message.guild,
        voiceChannel, // ห้องเสียงที่ต้องการเล่นเพลง
        textChannel: message.channel, // ห้องข้อความ
        volume: 100, // ระดับเสียงเพลง
        deafen: true, // ปิดหูฟัง
      },
      {
        skipOnError: true,
      }
    );
    await player.play();
  }
});
```


---

# 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://docs.lavaone.no-one.xyz/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.
