1.3.3 • Published 7 days ago

blue.ts v1.3.3

Weekly downloads
-
License
ISC
Repository
github
Last release
7 days ago
# npm add
npm install blue.ts
# yarn add
yarn add blue.ts
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");
1.3.3

7 days ago

1.3.2

15 days ago

1.3.1

16 days ago

1.2.2

16 days ago

1.3.0

16 days ago

1.2.1

23 days ago

1.0.1

1 month ago

1.0.0

1 month ago

4.0.1

1 month ago

4.0.0

1 month ago

4.3.7

1 month ago