npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@koenie06/discord.js-music

v1.3.0

Published

Create easily a discord.js music bot with this package!

Downloads

50

Readme

✨ Features

  • Customizable and easy to use.
  • Supports Youtube, Spotify, Soundcloud and much more..! (Watch out! Only some spotify songs are working, I am working on it..)
  • Automaticly makes a server queue.
  • Has been made with @discordjs/voice.
  • Supports youtube playlists. (More in the future..)

📥 Installation

Wait! Before you install, you need..

  • Node.js

  • Discord.js v13+

After this, you can finally install the package with:

$ npm install @koenie06/discord.js-music

🔎 Functions

There are a lot of functions, that are probably useful to know.

Music:

  • .play() - Plays the given music in the given channel.
  • .stop() - Stops the music whenever it is playing.
  • .skip() - Skips the current playing song.
  • .pause() - Pauses the current playing song.
  • .resume() - Resumes the playing song whenever it is paused.
  • .repeat() - Repeats the playing song forever, until it is turned off.
  • .volume() - Changes the music volume.
  • .jump() - Jumps to a the given queue number song.
  • .getQueue() - Returns a Array of queued songs.
  • .removeQueue() - Removes the given queue song number from the queue.

Checks:

Events:

  • playSong - Runs whenever a new song started playing.
  • addSong - Runs whenever a song has been added to the queue.
  • playList - Runs whenever a new song of a playlist started playing.
  • addList - Runs whenever a playlist has been added to the queue.
  • finish - Runs whenever all the queued songs are played.
/* Importing all the required stuff, you should know this. */
const { Client, Intents } = require('discord.js');
const music = require('@koenie06/discord.js-music');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_VOICE_STATES] });

/* This code will run when the client receives a interaction */
client.on('interactionCreate', async (interaction) => {
    if(interaction.isCommand()) {
        if(interaction.commandName === 'play') {

            /*
             * This function requires 3 options:
             * 1) Interaction. The interaction you got from the 'interactionCreate' event.
             * 2) Channel. The Voice Channel where the music is supposed to be played in.
             * 3) Song. A song name/URL that needs to be played.
            */

           const channel = interaction.member.voice.channel;
           const song = interaction.options.getString('song');

           music.play({
               interaction: interaction,
               channel: channel,
               song: song
           });
        };
    };
});

/* Log your client in with your token. */
client.login('Client token from https://discord.com/developers/applications');
/* Importing all the required stuff, you should know this. */
const { Client, Intents } = require('discord.js');
const music = require('@koenie06/discord.js-music');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_VOICE_STATES] });

/* This code will run when the client receives a interaction */
client.on('interactionCreate', async (interaction) => {
    if(interaction.isCommand()) {
        if(interaction.commandName === 'stop') music.stop({ interaction: interaction });
    };
});

/* Log your client in with your token. */
client.login('Client token from https://discord.com/developers/applications');
/* Importing all the required stuff, you should know this. */
const { Client, Intents } = require('discord.js');
const music = require('@koenie06/discord.js-music');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_VOICE_STATES] });

/* This code will run when the client receives a interaction */
client.on('interactionCreate', async (interaction) => {
    if(interaction.isCommand()) {
        if(interaction.commandName === 'skip') music.skip({ interaction: interaction });
    };
});

/* Log your client in with your token. */
client.login('Client token from https://discord.com/developers/applications');
/* Importing all the required stuff, you should know this. */
const { Client, Intents } = require('discord.js');
const music = require('@koenie06/discord.js-music');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_VOICE_STATES] });

/* This code will run when the client receives a interaction */
client.on('interactionCreate', async (interaction) => {
    if(interaction.isCommand()) {
        if(interaction.commandName === 'pause') music.pause({ interaction: interaction });
    };
});

/* Log your client in with your token. */
client.login('Client token from https://discord.com/developers/applications');
/* Importing all the required stuff, you should know this. */
const { Client, Intents } = require('discord.js');
const music = require('@koenie06/discord.js-music');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_VOICE_STATES] });

/* This code will run when the client receives a interaction */
client.on('interactionCreate', async (interaction) => {
    if(interaction.isCommand()) {
        if(interaction.commandName === 'resume') music.resume({ interaction: interaction });
    };
});

/* Log your client in with your token. */
client.login('Client token from https://discord.com/developers/applications');
/* Importing all the required stuff, you should know this. */
const { Client, Intents } = require('discord.js');
const music = require('@koenie06/discord.js-music');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_VOICE_STATES] });

/* This code will run when the client receives a interaction */
client.on('interactionCreate', async (interaction) => {
    if(interaction.isCommand()) {
        if(interaction.commandName === 'repeat') {

            /* 
             * Use 'true' to set the song on repeat.
             * Use 'false' to turn the repeat mode off when it is on.
            */

            const OnOrOff = interaction.options.getBoolean('onoff');

            music.repeat({
                interaction: interaction,
                value: onOrOff
            });
            
        };
    };
});

/* Log your client in with your token. */
client.login('Client token from https://discord.com/developers/applications');
/* Importing all the required stuff, you should know this. */
const { Client, Intents } = require('discord.js');
const music = require('@koenie06/discord.js-music');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_VOICE_STATES] });

/* This code will run when the client receives a interaction */
client.on('interactionCreate', async (interaction) => {
    if(interaction.isCommand()) {
        if(interaction.commandName === 'volume') {
            
            /*
             * Volume option needs to be an Integer and can't be higher than 100.
            */
            
            const volume = interaction.options.getInteger('volume');
            
            music.volume({
                interaction: interaction,
                volume: volume
            });
        };
    };
});

/* Log your client in with your token. */
client.login('Client token from https://discord.com/developers/applications');
/* Importing all the required stuff, you should know this. */
const { Client, Intents } = require('discord.js');
const music = require('@koenie06/discord.js-music');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_VOICE_STATES] });

/* This code will run when the client receives a interaction */
client.on('interactionCreate', async (interaction) => {
    if(interaction.isCommand()) {
        if(interaction.commandName === 'jump') {

            /*
             * Number option needs to be an Integer and has to be a valid queue number.
            */

            const number = interaction.options.getInteger('number');

            music.jump({
                interaction: interaction,
                number: number
            });
        };
    };
});

/* Log your client in with your token. */
client.login('Client token from https://discord.com/developers/applications');
/* Importing all the required stuff, you should know this. */
const { Client, Intents } = require('discord.js');
const music = require('@koenie06/discord.js-music');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_VOICE_STATES] });

/* This code will run when the client receives a interaction */
client.on('interactionCreate', async (interaction) => {
    if(interaction.isCommand()) {
        if(interaction.commandName === 'getqueue') console.log(await(music.getQueue({ interaction: interaction })));
    };
});

/* Log your client in with your token. */
client.login('Client token from https://discord.com/developers/applications');
/* Importing all the required stuff, you should know this. */
const { Client, Intents } = require('discord.js');
const music = require('@koenie06/discord.js-music');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_VOICE_STATES] });

/* This code will run when the client receives a interaction */
client.on('interactionCreate', async (interaction) => {
    if(interaction.isCommand()) {
        if(interaction.commandName === 'removequeue') {

            /*
             * Number option needs to be an Integer and has to be a valid queue number.
            */

            const number = interaction.options.getInteger('number');

            music.removeQueue({
                interaction: interaction,
                number: number 
            });

        };
    };
});

/* Log your client in with your token. */
client.login('Client token from https://discord.com/developers/applications');
/* Importing all the required stuff, you should know this. */
const { Client, Intents } = require('discord.js');
const music = require('@koenie06/discord.js-music');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_VOICE_STATES] });

/* This code will run when the client receives a interaction */
client.on('interactionCreate', async (interaction) => {
    if(interaction.isCommand()) {
        if(interaction.commandName === 'isconnected') {

            /*
             * This function returns a boolean whenever it is connected or not.
             * 'true' means that it is connected to a VoiceChannel.
             * 'false' means that it isn't connected to any VoiceChannel.
            */

            const isConnected = await music.isConnected({ interaction: interaction });
    
            interaction.reply({ content: isConnected === true ? 'I am connected!' : 'Welp.. I am not connected to any channel here.' });

        };
    };
});

/* Log your client in with your token. */
client.login('Client token from https://discord.com/developers/applications');
/* Importing all the required stuff, you should know this. */
const { Client, Intents } = require('discord.js');
const music = require('@koenie06/discord.js-music');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_VOICE_STATES] });

/* This code will run when the client receives a interaction */
client.on('interactionCreate', async (interaction) => {
    if(interaction.isCommand()) {
        if(interaction.commandName === 'ispaused') {

            /*
             * This function returns a boolean whenever it is paused or not.
             * 'true' means that the playing song is paused.
             * 'false' means that the playing song is still playing.
            */

            const isPaused = await music.isPaused({ interaction: interaction });
    
            interaction.reply({ content: isPaused === true ? 'I am waiting for you to resume..' : 'Yes yes, i am still playing music!' });

        };
    };
});

/* Log your client in with your token. */
client.login('Client token from https://discord.com/developers/applications');
/* Importing all the required stuff, you should know this. */
const { Client, Intents } = require('discord.js');
const music = require('@koenie06/discord.js-music');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_VOICE_STATES] });

/* This code will run when the client receives a interaction */
client.on('interactionCreate', async (interaction) => {
    if(interaction.isCommand()) {
        if(interaction.commandName === 'isresumed') {

            /*
             * This function returns a boolean whenever it is resumed or not.
             * 'true' means that the playing song is still playing.
             * 'false' means that the song is paused.
            */

            const isResumed = await music.isResumed({ interaction: interaction });
    
            interaction.reply({ content: isResumed === true ? 'Ofcourse i am still playing music!' : 'Sadly enough.. I got paused.' });

        };
    };
});

/* Log your client in with your token. */
client.login('Client token from https://discord.com/developers/applications');
/* Importing all the required stuff, you should know this. */
const { Client, Intents } = require('discord.js');
const music = require('@koenie06/discord.js-music');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_VOICE_STATES] });

/* This code will run when the client receives a interaction */
client.on('interactionCreate', async (interaction) => {
    if(interaction.isCommand()) {
        if(interaction.commandName === 'isrepeated') {

            /*
             * This function returns a boolean whenever it is resumed or not.
             * 'true' means that the playing song is on repeat.
             * 'false' means that the queue is just playing normally.
            */

            const isRepeated = await music.isRepeated({ interaction: interaction });
    
            interaction.reply({ content: isRepeated === true ? 'This song is in a infinite loop!' : 'Just playing the queue normally.' });

        };
    };
});

/* Log your client in with your token. */
client.login('Client token from https://discord.com/developers/applications');
/* Importing all the required stuff, you should know this. */
const { Client, Intents } = require('discord.js');
const music = require('@koenie06/discord.js-music');
const events = music.event;

events.on('playSong', async (channel, songInfo, requester) => {

    /* See all the 'songInfo' options by logging it.. */

    channel.send({
        content: `Started playing the song [${songInfo.title}](${songInfo.url}) by \`${songInfo.author}\`.
        This was requested by ${requester.tag} (${requester.id})`
    });

});

events.on('addSong', async (channel, songInfo, requester) => {

    /* See all the 'songInfo' options by logging it.. */

    channel.send({
        content: `Added the song [${songInfo.title}](${songInfo.url}) by \`${songInfo.author}\` to the queue.
        Added by ${requester.tag} (${requester.id})`
    });

});

events.on('playList', async (channel, playlist, songInfo, requester) => {

    /* See all the 'songInfo' and 'playlist' options by logging it.. */

    channel.send({
        content: `Started playing the song [${songInfo.title}](${songInfo.url}) by \`${songInfo.author}\` of the playlist ${playlist.title}.
        This was requested by ${requester.tag} (${requester.id})`
    });

});

events.on('addList', async (channel, playlist, requester) => {

    /* See all the 'playlist' options by logging it.. */

    channel.send({
        content: `Added the playlist [${playlist.title}](${playlist.url}) with ${playlist.videos.length} amount of videos to the queue.
        Added by ${requester.tag} (${requester.id})`
    });

});

events.on('finish', async (channel) => {

    channel.send({
        content: 'Party has been ended!'
    });

});

/* Log your client in with your token. */
client.login('Client token from https://discord.com/developers/applications');

🔚 The End

Did you really scroll this far? Holy sh*t! Here a cookie for you, hope you have a nice day. :)

♥ Koenie06