Git Product home page Git Product logo

discord-ytdl-core's Introduction

Simple ytdl wrapper for discord bots with custom ffmpeg args support.

Documentation

Discord YTDL Core

Installing

npm i discord-ytdl-core

https://www.npmjs.com/package/discord-ytdl-core

Please install an Opus engine & FFmpeg before using this package.

Supported Opus Engines:

Options

This package provides 2 extra options excluding ytdl-core options. They are: seek & encoderArgs.

  • seek: This parameter takes the time in seconds. If this option is provided, it will return the stream from that frame. Seek option is provided here because discord.js seek doesn't work for ogg/opus & webm/opus stream. This option is ignored when the supplied parameter type isn't a number.

  • encoderArgs: This parameter takes the Array of FFmpeg arguments. Invalid args will throw error and crash the process. This option is ignored when the supplied parameter type isn't array. Invalid FFmpeg args might crash the process.

  • Other options are the options for ytdl-core.

Example

const ytdl = require("discord-ytdl-core");
const Discord = require("discord.js");
const client = new Discord.Client();

client.on("ready", () => {
    console.log("ready")
});

client.on("message", msg => {
    if (msg.author.bot || !msg.guild) return;
    if (msg.content === "??play") {
        if (!msg.member.voice.channel) return msg.channel.send("You're not in a voice channel?");
        let stream = ytdl("https://youtube.com/watch?v=ERu6jh_1gR0", {
            filter: "audioonly",
            encoderArgs: ['-af', 'equalizer=f=40:width_type=h:width=50:g=10'] // FFmpeg args array (optional)
        });
        
        msg.member.voice.channel.join()
        .then(connection => {
            connection.play(stream, {
                type: "opus" // type: opus is compulsory because this package returns opus stream
            })
            .on("finish", () => {
                msg.guild.me.voice.channel.leave();
            })
        });
    }
});

client.login("TOKEN");

Example Bots

If you have a bot which uses this package, create a Pull Request.

Other functions

This package can do all the functions of normal ytdl-core.

Related

Developers

Join our Official Discord Server

discord-ytdl-core's People

Contributors

twlite avatar androz2091 avatar dependabot-preview[bot] avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.