Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
discord-temp-channels
Advanced tools
Readme
Discord Temp Channels is a framework to facilitate the creation of a temporary voice channels system using Discord.js (v13)!
npm install --save discord-temp-channels
const Discord = require("discord.js");
const client = new Discord.Client();
const TempChannels = require("discord-temp-channels");
const tempChannels = new TempChannels(client);
// Register a new main channel
tempChannels.registerChannel("channel-id", {
childCategory: "category-id",
childAutoDeleteIfEmpty: true,
childMaxUsers: 3,
childFormat: (member, count) => `#${count} | ${member.user.username}'s lounge`
});
client.login("YOUR_TOKEN");
You have to register a channel to indicate to the package which channel will be used to create child channels.
// Register a new parent channel
tempChannels.registerChannel("channel-id", {
childCategory: "category-id",
childAutoDeleteIfEmpty: true,
childAutoDeleteIfOwnerLeaves: true,
childMaxUsers: 3,
childBitrate: 64000,
childFormat: (member, count) => `#${count} | ${member.user.username}'s lounge`
});
channelID: The ID of the channel the users will have to join to create a new channel.
options.childCategory: Optional - This will be the category ID in which the new channels will be created.
options.childAutoDeleteIfEmpty: Whether, when a channel is empty, it should be deleted.
options.childAutoDeleteIfOwnerLeaves: Whether, when the member who created a channel left it, it should be deleted (even if it's not empty).
options.childMaxUsers: Optional - This will be the maximum number of users that can join a channel
options.childBitrate: Optional - This will be the new channel bitrate
options.childFormat: This is a function which takes two parameters: the member (the one who created the channel, and the number of voice channels created from the same parent channel)
You can un-register a channel, so the users who join the it won't create a new channel.
// Unregister a parent channel
tempChannels.unregisterChannel("channel-id");
channelID: The ID of the channel you want unregister.
// Emitted when a child channel is created
tempChannels.on("childCreate", (member, channel, parentChannel) => {
console.log(member); // The member who created the new channel
console.log(channel); // The channel which was created
console.log(parentChannel); // The channel the member joined to create the new channel
});
// Emitted when a child channel is deleted
tempChannels.on("childDelete", (member, channel, parentChannel) => {
console.log(member); // The member who caused the deletion of the channel
console.log(channel); // The channel which was deleted
console.log(parentChannel); // The channel the member joined to create the deleted channel
});
// Emitted when a channels is registered
tempChannels.on("channelRegister", (channelData) => {
console.log(channelData);
/*
{
"channelID": "03909309383083"
"options": {
"childCategory": "380398303838398390",
"childAutoDeleteIfEmpty": true
etc...
}
}
*/
});
// Emitted when a channels is unregistered
tempChannels.on("channelUnregister", (channelData) => {
console.log(channelData);
/*
{
"channelID": "03909309383083"
"options": {
"childCategory": "380398303838398390",
"childAutoDeleteIfEmpty": true
etc...
}
}
*/
});
// Emitted when there is an error
tempChannels.on("error", (err, message) => {
console.log(err);
console.log(message);
});
This code stores temporary channels data in a database (quick.db in this case). When the bot starts, it registers all the channels in the database and there is a command to add new main channels (!set).
const Discord = require("discord.js");
const client = new Discord.Client();
const TempChannels = require("discord-temp-channels");
const tempChannels = new TempChannels(client);
const db = require("quick.db");
client.on("ready", () => {
if (!db.get("temp-channels")) db.set("temp-channels", []);
db.get("temp-channels").forEach((channelData) => {
tempChannels.registerChannel(channelData.channelID, channelData.options);
});
});
client.on("message", (message) => {
if(message.content.startsWith("!set")){
if(tempChannels.channels.some((channel) => channel.channelID === message.member.voice.channel.id)){
return message.channel.send("Your voice channel is already a main voice channel");
}
const options = {
childAutoDeleteIfEmpty: true,
childAutoDeleteIfOwnerLeaves: true,
childMaxUsers: 3,
childBitrate: 64000,
childFormat: (member, count) => `#${count} | ${member.user.username}'s lounge`
};
tempChannels.registerChannel(message.member.voice.channel.id, options);
db.push("temp-channels", {
channelID: message.member.voice.channel.id,
options: options
});
message.channel.send("Your voice is now a main voice channel!");
}
});
client.login("YOUR_TOKEN");
FAQs
Simple framework to facilitate the creation of a temporary voice channels system using Discord.js
The npm package discord-temp-channels receives a total of 32 weekly downloads. As such, discord-temp-channels popularity was classified as not popular.
We found that discord-temp-channels demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.