Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
DartJS is a Discord.js voice framework that aims to provide similar voice interface of Discord.js v12.
$ npm i --save dartjs
You may need to install encryption library and opus engine as well.
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.
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");
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");
require("dartjs").injectSmoothVolume();
See https://github.com/discord-player/voice-recorder-example for a complete voice recorder example.
FAQs
Very simple framework that provides discord.js v12 voice interface
The npm package dartjs receives a total of 12 weekly downloads. As such, dartjs popularity was classified as not popular.
We found that dartjs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.