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

dartjs-v14

v1.0.1

Published

Very simple framework that provides discord.js v12 voice interface for discord.js v14.

Downloads

32

Readme

DartJS

DartJS is a Discord.js voice framework that aims to provide similar voice interface of Discord.js v12.

Installation

$ npm i --save @bes/dartjs

You may need to install encryption library and opus engine as well.

Features

  • supports voice receiving
  • supports voice sending
  • close to discord.js v12 voice api
  • injects nothing to your client or discord.js

Note

Use <Dispatcher>.once instead of <Dispatcher>.on. Since the concept of StreamDispatcher is gone with the voice rewrite, the StreamDispatcher polyfill does not work exactly like discord.js v12 voice. Using .on to handle events may cause the dispatcher to trigger the event multiple times since same dispatcher instance is used throughout the session. Using .once to handle events will only trigger the event once per your music bot session and wont break your code since .once removes the listener immediately after the event is emitted.

Example

Music Bot

const Discord = require("discord.js");
const client = new Discord.Client({
    intents: ...
});
const { DartVoiceManager } = require("@bes/dartjs");
const voiceManager = new DartVoiceManager(client);
const ytdl = require("ytdl-core");

client.on("ready", () => console.log("Bot is online!"));

client.on("messageCreate", message => {
    if (message.author.bot) return;

    if (message.content === "!play") {
        voiceManager.join(message.member.voice.channel)
            .then(connection => {
            const dispatcher = connection.play(ytdl("https://www.youtube.com/watch?v=dQw4w9WgXcQ"));
            dispatcher.once("start", () => message.channel.send("Music started!"));
            dispatcher.once("finish", () => {
                message.channel.send("Music finished!");
            });
        });
    }
});

client.login("XXX");

Voice Receiving

const Discord = require("discord.js");
const client = new Discord.Client({
    intents: ...
});
const { DartVoiceManager } = require("@bes/dartjs");
const voiceManager = new DartVoiceManager(client);
const fs = require("fs");

client.on("ready", () => console.log("Bot is online!"));

client.on("messageCreate", message => {
    if (message.author.bot) return;

    if (message.content === "!record") {
        voiceManager.join(message.member.voice.channel)
            .then(connection => {
                const receiver = connection.receiver.createStream(message.member, {
                    mode: "pcm",
                    end: "silence"
                });

                const writer = receiver.pipe(fs.createWriteStream("./recorded.pcm"));

                writer.on("finish", () => {
                    message.channel.send("Finished recording!");
                });
            });
    }
});

client.login("XXX");

See https://github.com/discord-player/voice-recorder-example for a complete voice recorder example.

Smooth Volume

This feature enables smooth volume transition.

This library will attempt to polyfill smooth volume api by default. This can be disabled by setting DARTJS_DISABLE_INJECTION in env.

Example:

// injecting manually
require("@bes/dartjs").injectSmoothVolume();

// Set smoothness before playing
dispatcher.play(stream, {
    // use whatever value feels better
    volumeSmoothness: 0.08
});

// setting smoothness on-the-fly
dispatcher.setVolumeSmoothness(0.08)