Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Releases: twlite/dartjs

1.2.0

20 Apr 12:06
Compare
Choose a tag to compare

Updates

  • add ignorePrevious option on play method of StreamDispatcher
  • add volumePercentage and setVolumePercentage
  • add immediate and next methods:
    • immediate(() => unknown): Runs immediately after the end of a resource
    • next(() => unknown): Runs immediately before handling new resource

Full Changelog: v1.1.1...v1.2.0

1.1.1

01 Mar 11:37
Compare
Choose a tag to compare

Updates

  • add VoiceManager#leave method
  • add support for converted and unknown stream types
  • refactor VoiceConnection#disconnect to use disconnect
  • add VoiceConnection#destroy (same as VoiceConnection#disconnect of older versions)
  • VoiceConnection#ping now returns udp latency

Documentation

  • add voice receiving example
  • other minor changes

Example

Voice Receiving

const Discord = require("discord.js");
const client = new Discord.Client({
    intents: [
        Discord.Intents.GUILDS,
        Discord.Intents.GUILD_VOICE_STATES,
        Discord.Intents.GUILD_MESSAGES,
        Discord.Intents.GUILD_MEMBERS
    ]
});
const { DartVoiceManager } = require("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");

Voice Sending

const Discord = require("discord.js");
const client = new Discord.Client({
    intents: [
        Discord.Intents.GUILDS,
        Discord.Intents.GUILD_VOICE_STATES,
        Discord.Intents.GUILD_MESSAGES
    ]
});
const { DartVoiceManager } = require("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");

Full Changelog: v1.1.0...v1.1.1

1.1.0

19 Feb 14:35
Compare
Choose a tag to compare

Updates

  • implement experimental voice receiver
  • add missing methods from StreamDispatcher

Fixes

  • fix event handlers
  • handle disconnect errors

Full Changelog: v1.0.1...v1.1.0

1.0.1

21 Aug 14:12
Compare
Choose a tag to compare

Updates

  • feat(StreamDispatcher): add play options

1.0.0

21 Aug 11:27
eeb585a
Compare
Choose a tag to compare

Initial Release