1.1.4 • Published 4 years ago

lavaone v1.1.4

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

Untitled (2)

Installation

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

npm install lavaone -s

How to use the module

Documentation: https://docs.lavaone.no-one.xyz/

วิธีใช้การโมดูล LavaOne

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");

วิธีใช้การค้นหาเพลงจาก youtube

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();
  }
});
1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago