1.0.3 • Published 3 years ago

discord-songs.js v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

wanna make DISCORD song apps? follow these amazing steps and you will be at your destination

  • get discord.js
npm i discord.js

get discord.js-player

npm i discord.js-player

code example (you can use)

//Regular discord.js setup
const { Client } = require("discord.js");
const client = new Client();
const TOKEN = "YOUR_TOKEN";//app TOKEN
const PREFIX = "!";//any PREFIX
client.login(TOKEN);

//songs Setup
const { Player, EVENTS } = require("discord.js-player");
const { EVT_TRACK_START, EVT_TRACK_ADD } = EVENTS;
const YOUR_SPOTIFY_ID = "";// spotify ID
const YOUR_SPOTIFY_SECRET = "";// spotify SECRET

// create a new Player (you need a Spotify ID/Secret)
client.music = new Player(YOUR_SPOTIFY_ID, YOUR_SPOTIFY_SECRET, {canUseCache: true});
client.music.connect();

//optional Events
client.music.on(EVT_TRACK_START, (channel, track) => {
    channel.send(`Track ${track.title} started playing!`);
});
client.music.on(EVT_TRACK_ADD, (channel, tracks) => {
    channel.send(`Added ${tracks.length} to the queue!`);
});

client.on("message", async (message) => {
    if (!message.content.startsWith(PREFIX)) return;
    
    const args = message.content.slice(PREFIX.length).trim().split(/ +/g);
    const command = args.shift().toLowerCase();

    //(spotify URL)
    //(youtube URL)
    //(youtube or spotify NAME)
    if(command === "play"){
        
        //make sure you are connected inside of a VC
        const voiceChannel = message.member.voice.channel
        let queue = client.music.getQueue(message.guild.id)
        //no queue, one will be created
        if (!queue) queue = client.music.createQueue(message.guild.id, message.channel, voiceChannel, [], {emit: {trackStart: true}})
        //added by is optional
        client.music.play(queue.id, args.join(' '), {addedBy: message.author.username})
        
    } else if(command === "queue") {
        const shownQueue = client.music.getQueue(message.guild.id).showQueue({
            limit: 10,
            show: {
                queueNumber: true,
                addedBy: true,
                align: true,
                alignmentSpace: 70
            }
        })
        await message.channel.send(shownQueue.join('\n'))
        
    }
});

i hope you guys enjoy ;)

  • CREDITS (Androz)
  • MADE BY (MrTahfaru)
1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago