Skip to content

ftrapture/blue.ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blue.ts Banner

Blue.ts

A powerful, simple, and effective stable Lavalink client developed in TypeScript.

FeaturesRequirementsInstallationQuick StartDocumentationIssuesLicense



✨ Features

  • 💿 Audio playback with fully-featured controls
  • 🎚️ Filters support
  • 🔍 Best search engines: YouTube, Spotify, SoundCloud
  • 🔄 Advanced autoplay feature
  • ⚡ Faster, simple, and stable client
  • 🆙 Supports the latest Lavalink version: 4.0.4
  • 🌐 Compatible with discord.js, eris, oceanicjs
  • 🔌 Plugins support

⚙️ Requirements

  • Node.js Version: >= 16.9.0
  • A Lavalink server, here are some free Lavalink servers: Click Me
  • Discord Bot token to get started

📥 Installation

# npm add
npm install blue.ts
# yarn add
yarn add blue.ts

🚀 Quick Start with Discord.js 13

const { Client, Intents } = require("discord.js");
const { Blue, Events, Types, Library } = require("blue.ts");

const client = new Client({
  //...client constructor
});

//Lavalink Nodes
const nodes = [
  {
    host: "localhost",
    port: 2333,
    password: "youshallnotpass",
    secure: false
  }
];

//Blue Manager Options
const options = {
  spotify: {
    client_id: "CLIENT_ID",  //spotify client ID
    client_secret: "CLIENT_SECRET" //spotify client Secret
  },
  autoplay: true,
  version: "v4",
  library: Library.DiscordJs
};

//Declaring the manager
client.manager = new Blue(nodes, options);

//ready event handler to initiate the manager
client.on("ready", async () => {
  console.log("Client is ready!");
  client.manager.init(client);
});

client.on("messageCreate", async (message) => {
  if(message.author.bot) return;
  if(message.content.startsWith("!play")) {

    let player = client.manager.players.get(message.guild.id);

    if(!player) {
      player = await client.manager.create({
        voiceChannel: message.member?.voice?.channel?.id || null,
        textChannel: message.channel?.id,
        guildId: message.guild.id,
        selfDeaf: true,
        selfMute: false
      });
    }

    const res = await client.manager.search({ query: "summertime sadness", source: "spotify" }, message.author);

    if (!res) return message.reply("song not found");

    if (res.loadType == Types.LOAD_SP_ALBUMS || res.loadType == Types.LOAD_SP_PLAYLISTS) {
      player.queue.add(...res.tracks);
      message.reply(`Loaded **${res.length}** tracks from \`${res.name}\``);
    } else {
      player.queue.add(res.tracks[0]);
      message.reply(`Track: **${res.tracks[0].info.title}** added to queue.`);
    }
    if (!player.queue?.current)
      player.play();
  }
});

//Replace the TOKEN with the actual bot token
client.login("TOKEN");

📚 Documentation

Check out the documentation for detailed usage instructions and examples.


🐞 Issues

For any inquiries or issues, feel free to open an issue on GitHub.


📜 License

This project is licensed under the MIT License.



About

Blue.ts is a powerful simple but effective stable lavalink client developed in typescript.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published