This repository has been archived by the owner on Nov 1, 2022. It is now read-only.
Releases: twlite/dartjs
Releases · twlite/dartjs
1.2.0
Updates
- add
ignorePrevious
option onplay
method ofStreamDispatcher
- add
volumePercentage
andsetVolumePercentage
- add
immediate
andnext
methods:immediate(() => unknown)
: Runs immediately after the end of a resourcenext(() => unknown)
: Runs immediately before handling new resource
Full Changelog: v1.1.1...v1.2.0
1.1.1
Updates
- add
VoiceManager#leave
method - add support for
converted
andunknown
stream types - refactor
VoiceConnection#disconnect
to usedisconnect
- add
VoiceConnection#destroy
(same asVoiceConnection#disconnect
of older versions) VoiceConnection#ping
now returnsudp
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
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