### Build and Start Docker Environment Source: https://github.com/sudhanplayz/discord-musicbot/blob/v5/README.md This command builds the Docker images and starts the bot and Lavalink server in detached mode. This is used for containerized deployment, simplifying the setup process. It requires Docker and Docker Compose to be installed. ```sh docker-compose up -d --build ``` -------------------------------- ### Install Dependencies and Deploy Commands (npm) Source: https://github.com/sudhanplayz/discord-musicbot/blob/v5/README.md This command installs all necessary project dependencies using npm and then deploys the slash commands for the bot. This is a crucial step for initializing bot functionality. It assumes you have Node.js and npm installed. ```sh npm install npm run deploy ``` -------------------------------- ### Start the Bot (Node.js) Source: https://github.com/sudhanplayz/discord-musicbot/blob/v5/README.md This command starts the Discord Music Bot application using Node.js. Ensure all dependencies are installed and configurations are set up before running this command. ```sh node index.js ``` -------------------------------- ### Install Dependencies Source: https://github.com/sudhanplayz/discord-musicbot/wiki/Installation-on-a-Linux-server This command installs all the necessary Node.js packages for the Discord Music Bot to function. It reads the 'package.json' file to determine which dependencies to download. ```bash npm install ``` -------------------------------- ### Run Development Server (Bash) Source: https://github.com/sudhanplayz/discord-musicbot/blob/v5/dashboard/README.md Commands to start the Next.js development server using npm or yarn. This allows for local development and testing of the application. ```bash npm run dev # or yarn dev ``` -------------------------------- ### Install Dependencies and Deploy Commands (yarn) Source: https://github.com/sudhanplayz/discord-musicbot/blob/v5/README.md This command installs all necessary project dependencies using yarn and then deploys the slash commands for the bot. This is an alternative to using npm for dependency management and command deployment. ```sh yarn install yarn deploy ``` -------------------------------- ### Next.js API Route Example (JavaScript) Source: https://github.com/sudhanplayz/discord-musicbot/blob/v5/dashboard/README.md An example of an API route handler in Next.js. This file, typically located in the 'pages/api/' directory, defines an endpoint that can be accessed via HTTP requests. ```javascript export default function handler(req, res) { res.status(200).json({ text: 'Hello' }); } ``` -------------------------------- ### Clone Discord Music Bot Repository Source: https://github.com/sudhanplayz/discord-musicbot/wiki/Installation-on-a-Linux-server This command clones the Discord Music Bot repository from GitHub to your local machine. After cloning, navigate into the created directory to proceed with the setup. ```bash git clone https://github.com/SudhanPlayz/Discord-MusicBot.git cd Discord-MusicBot ``` -------------------------------- ### Manage Dockerized Discord Music Bot Services (Bash) Source: https://context7.com/sudhanplayz/discord-musicbot/llms.txt Provides bash commands for managing the Dockerized Discord music bot and Lavalink services. It includes commands to start services in detached mode, view logs, and stop all running services. ```bash # Start bot and Lavalink with Docker docker-compose up -d --build # View logs docker-compose logs -f bot # Stop services docker-compose down ``` -------------------------------- ### GET /api/data Source: https://context7.com/sudhanplayz/discord-musicbot/llms.txt Retrieves basic information about the Discord Music Bot, such as its username, version, available commands, and login status. ```APIDOC ## GET /api/data ### Description Returns basic bot information including username, version, available commands, and authentication status. ### Method GET ### Endpoint /api/data ### Parameters #### Query Parameters None #### Request Body None ### Request Example ```javascript const axios = require('axios'); const response = await axios.get('http://localhost:4200/api/data'); console.log(response.data); ``` ### Response #### Success Response (200) - **name** (string) - The username of the bot. - **version** (string) - The current version of the bot. - **commands** (array) - A list of available bot commands, each with a name and description. - **inviteURL** (string) - The OAuth2 invite URL for the bot. - **loggedIn** (boolean) - Indicates if the user is currently logged in. #### Response Example ```json { "name": "MusicBot", "version": "5.0.0-beta", "commands": [ { "name": "play", "description": "Searches and plays the requested song" }, { "name": "pause", "description": "Pauses the current playing track" }, { "name": "skip", "description": "Skip the current song" } ], "inviteURL": "https://discord.com/oauth2/authorize?client_id=...", "loggedIn": false } ``` ``` -------------------------------- ### GET /api/dashboard Source: https://context7.com/sudhanplayz/discord-musicbot/llms.txt Fetches dashboard statistics for the music bot, including metrics like commands executed, user count, server count, and songs played. Requires user authentication. ```APIDOC ## GET /api/dashboard ### Description Returns dashboard statistics including commands executed, user count, server count, and songs played. Requires authentication. ### Method GET ### Endpoint /api/dashboard ### Parameters #### Query Parameters None #### Request Body None ### Request Example ```javascript const axios = require('axios'); const response = await axios.get('http://localhost:4200/api/dashboard', { headers: { 'Cookie': 'connect.sid=your-session-cookie' } }); console.log(response.data); ``` ### Response #### Success Response (200) - **commandsRan** (integer) - The total number of commands executed. - **users** (integer) - The total number of users interacting with the bot. - **servers** (integer) - The number of Discord servers the bot is in. - **songsPlayed** (integer) - The total number of songs played by the bot. #### Response Example ```json { "commandsRan": 1543, "users": 12453, "servers": 38, "songsPlayed": 8921 } ``` ``` -------------------------------- ### Fetch Bot Data via API (JavaScript) Source: https://context7.com/sudhanplayz/discord-musicbot/llms.txt Retrieves basic bot information such as username, version, commands, and authentication status from the bot's API. This endpoint is useful for external applications or dashboards to get general bot status. It requires no authentication. ```javascript const axios = require('axios'); // Fetch bot data from the API const response = await axios.get('http://localhost:4200/api/data'); console.log(response.data); // Output: // { // name: "MusicBot", // version: "5.0.0-beta", // commands: [ // { name: "play", description: "Searches and plays the requested song" }, // { name: "pause", description: "Pauses the current playing track" }, // { name: "skip", description: "Skip the current song" } // ], // inviteURL: "https://discord.com/oauth2/authorize?client_id=...", // loggedIn: false // } ``` -------------------------------- ### Configure Lavalink Manager Events with JavaScript Source: https://context7.com/sudhanplayz/discord-musicbot/llms.txt Configures Lavalink node events and manages the music player lifecycle. This includes handling node connections, track start events, and queue end events to ensure smooth music playback and bot behavior. ```javascript const { Manager } = require("erela.js"); // Manager initialization in DiscordMusicBot.build() this.manager = new Manager({ plugins: [ new deezer(), new AppleMusic(), new spotify(), new facebook(), new filters() ], autoPlay: true, nodes: this.config.nodes, send: (id, payload) => { let guild = client.guilds.cache.get(id); if (guild) { guild.shard.send(payload); } } }) .on("nodeConnect", (node) => { console.log(`Node: ${node.options.identifier} | Lavalink node is connected.`); }) .on("trackStart", async (player, track) => { client.songsPlayed++; let trackStartedEmbed = new MessageEmbed() .setAuthor({ name: "Now playing", iconURL: client.config.iconURL }) .setDescription(`[${track.title}](${track.uri})`) .addFields( { name: "Requested by", value: `${track.requester}`, inline: true }, { name: "Duration", value: track.isStream ? ``LIVE`` : ``${prettyMilliseconds(track.duration, { colonNotation: true })}``, inline: true } ) .setThumbnail(track.displayThumbnail("maxresdefault")); let nowPlaying = await client.channels.cache .get(player.textChannel) .send({ embeds: [trackStartedEmbed], components: [client.createController(player.options.guild, player)] }); player.setNowplayingMessage(client, nowPlaying); }) .on("queueEnd", async (player, track) => { const autoQueue = player.get("autoQueue"); const twentyFourSeven = player.get("twentyFourSeven"); if (autoQueue) { // Search for related tracks on YouTube const search = `https://www.youtube.com/watch?v=${track.identifier}&list=RD${track.identifier}`; const res = await player.search(search, player.get("requester")); player.play(res.tracks[0]); } else if (!twentyFourSeven) { setTimeout(() => { if (!player.playing && player.state !== "DISCONNECTED") { player.destroy(); } }, client.config.disconnectTime); } }); ``` -------------------------------- ### Manage Discord Slash Commands Deployment (Bash) Source: https://context7.com/sudhanplayz/discord-musicbot/llms.txt Provides bash commands for deploying and managing slash commands for the Discord bot. These commands leverage npm scripts to execute the deployment logic, allowing for global deployment, guild-specific deployment for testing, and removal of commands. ```bash # Deploy slash commands globally npm run deploy # Deploy to specific guild (faster for testing) npm run guild # Remove all global commands npm run destroy-global # Remove guild-specific commands npm run destroy-guild ``` -------------------------------- ### Deploy Discord Music Bot with Lavalink using Docker Compose (YAML) Source: https://context7.com/sudhanplayz/discord-musicbot/llms.txt Defines services for running the Discord music bot and Lavalink server using Docker Compose. This configuration handles service dependencies, networking, volume mounts for Lavalink configuration, and environment variables for bot credentials. ```yaml # docker-compose.yml version: '3.8' services: lavalink: image: fredboat/lavalink:latest container_name: lavalink restart: unless-stopped volumes: - ./docker/application.yml:/opt/Lavalink/application.yml ports: - "2333:2333" networks: - musicbot bot: build: . container_name: discord-musicbot restart: unless-stopped depends_on: - lavalink environment: - token=${DISCORD_TOKEN} - clientId=${CLIENT_ID} - clientSecret=${CLIENT_SECRET} networks: - musicbot networks: musicbot: ``` -------------------------------- ### Play Command Implementation (JavaScript) Source: https://context7.com/sudhanplayz/discord-musicbot/llms.txt Implements the '/play' slash command for the Discord Music Bot. It allows users to search for and play music from various sources like YouTube, Spotify, Deezer, Apple Music, and Facebook. The command handles connecting to voice channels, searching for tracks, and adding them to the playback queue. ```javascript // In Discord chat: // /play query: "never gonna give you up" // Command implementation const SlashCommand = require("../../lib/SlashCommand"); const command = new SlashCommand() .setName("play") .setDescription("Searches and plays the requested song") .addStringOption((option) => option .setName("query") .setDescription("What am I looking for?") .setAutocomplete(true) .setRequired(true) ) .setRun(async (client, interaction, options) => { let channel = await client.getChannel(client, interaction); let player = client.createPlayer(interaction.channel, channel); if (player.state !== "CONNECTED") { player.connect(); } let query = options.getString("query", true); let res = await player.search(query, interaction.user); if (res.loadType === "TRACK_LOADED" || res.loadType === "SEARCH_RESULT") { player.queue.add(res.tracks[0]); if (!player.playing && !player.paused && !player.queue.size) { player.play(); } } if (res.loadType === "PLAYLIST_LOADED") { player.queue.add(res.tracks); if (!player.playing && !player.paused) { player.play(); } } }); ``` -------------------------------- ### Configure Discord Bot and Lavalink Settings (JavaScript) Source: https://context7.com/sudhanplayz/discord-musicbot/llms.txt Sets up the bot's core configuration, including Discord API tokens, Lavalink node details, and various music playback settings. This file, `config.js`, is essential for customizing bot behavior and its connection to the Lavalink server. ```javascript module.exports = { token: process.env.token || "your-bot-token", clientId: process.env.clientId || "your-client-id", clientSecret: process.env.clientSecret || "your-client-secret", port: 4200, // Music settings defaultVolume: 100, disconnectTime: 30000, twentyFourSeven: false, autoQueue: false, autoPause: true, autoLeave: false, // Lavalink nodes configuration nodes: [ { identifier: "Main Node", host: "localhost", port: 2333, password: "youshallnotpass", retryAmount: 200, retryDelay: 40, secure: false } ], // Dashboard website: "http://localhost:4200", cookieSecret: "random-secret-string", scopes: ["identify", "guilds", "applications.commands"], embedColor: "#2f3136", presence: { status: "online", activities: [ { name: "Music", type: "LISTENING" } ] } }; ``` -------------------------------- ### Create Music Player with JavaScript Source: https://context7.com/sudhanplayz/discord-musicbot/llms.txt Creates a new music player instance for a Discord guild, configuring voice and text channels. This function is essential for initializing music playback capabilities within the bot. ```javascript const DiscordMusicBot = require("./lib/DiscordMusicBot"); // Create bot client const client = new DiscordMusicBot(); // Create player in interaction handler client.on("interactionCreate", async (interaction) => { const textChannel = interaction.channel; const voiceChannel = interaction.member.voice.channel; // Creates Erela.js player with configuration const player = client.createPlayer(textChannel, voiceChannel); // Returns player configured with: // - guild ID // - voice channel ID // - text channel ID // - server deafen setting // - default volume if (player.state !== "CONNECTED") { player.connect(); } // Player is now ready for search and playback const result = await player.search("rickroll", interaction.user); player.queue.add(result.tracks[0]); player.play(); }); ``` -------------------------------- ### Display Queue Command (JavaScript) Source: https://context7.com/sudhanplayz/discord-musicbot/llms.txt Displays the current music queue, including the currently playing song and upcoming tracks. Supports pagination for large queues and shows duration and volume information. ```javascript // In Discord chat: // /queue // Command shows current track and queued tracks with duration info const command = new SlashCommand() .setName("queue") .setDescription("Shows the current queue") .setRun(async (client, interaction, options) => { let player = client.manager.players.get(interaction.guild.id); if (!player.queue.size || player.queue.size === 0) { let song = player.queue.current; const queueEmbed = new MessageEmbed() .setColor(client.config.embedColor) .setDescription(`**♪ | Now playing:** [${song.title}](${song.uri})`) .addFields( { name: "Duration", value: song.isStream ? ``LIVE`` : ``${pms(player.position, { colonNotation: true })} / ${pms(song.duration, { colonNotation: true })}``, inline: true }, { name: "Volume", value: ``${player.volume}``, inline: true } ); await interaction.editReply({ embeds: [queueEmbed] }); } else { // Map queue tracks and paginate const mapping = player.queue.map( (t, i) => `` ${++i} ` [${t.title}](${t.uri}) [${t.requester}]` ); const chunk = lodash.chunk(mapping, 10); const pages = chunk.map((s) => s.join("\n")); // Display with navigation buttons } }); ``` -------------------------------- ### NextUI Color Theme Configuration Source: https://github.com/sudhanplayz/discord-musicbot/blob/v5/dashboard/out/servers.html This snippet defines various color variables for the NextUI framework, used for styling the Discord music bot. It includes primary, secondary, status, neutral, and accent colors, along with specific color shades for blue, purple, green, and yellow. These variables are essential for maintaining a consistent visual theme throughout the application. ```css colors-secondaryBorder:var(--nextui-colors-purple500);--nextui-colors-secondaryBorderHover:var(--nextui-colors-purple600);--nextui-colors-secondarySolidHover:var(--nextui-colors-purple700);--nextui-colors-secondarySolidContrast:var(--nextui-colors-white);--nextui-colors-secondaryShadow:var(--nextui-colors-purple500);--nextui-colors-successLight:var(--nextui-colors-green200);--nextui-colors-successLightHover:var(--nextui-colors-green300);--nextui-colors-successLightActive:var(--nextui-colors-green400);--nextui-colors-successLightContrast:var(--nextui-colors-green700);--nextui-colors-success:var(--nextui-colors-green600);--nextui-colors-successBorder:var(--nextui-colors-green500);--nextui-colors-successBorderHover:var(--nextui-colors-green600);--nextui-colors-successSolidHover:var(--nextui-colors-green700);--nextui-colors-successSolidContrast:var(--nextui-colors-white);--nextui-colors-successShadow:var(--nextui-colors-green500);--nextui-colors-warningLight:var(--nextui-colors-yellow200);--nextui-colors-warningLightHover:var(--nextui-colors-yellow300);--nextui-colors-warningLightActive:var(--nextui-colors-yellow400);--nextui-colors-warningLightContrast:var(--nextui-colors-yellow700);--nextui-colors-warning:var(--nextui-colors-yellow600);--nextui-colors-warningBorder:var(--nextui-colors-yellow500);--nextui-colors-warningBorderHover:var(--nextui-colors-yellow600);--nextui-colors-warningSolidHover:var(--nextui-colors-yellow700);--nextui-colors-warningSolidContrast:var(--nextui-colors-white);--nextui-colors-warningShadow:var(--nextui-colors-yellow500);--nextui-colors-errorLight:var(--nextui-colors-red200);--nextui-colors-errorLightHover:var(--nextui-colors-red300);--nextui-colors-errorLightActive:var(--nextui-colors-red400);--nextui-colors-errorLightContrast:var(--nextui-colors-red600);--nextui-colors-error:var(--nextui-colors-red600);--nextui-colors-errorBorder:var(--nextui-colors-red500);--nextui-colors-errorBorderHover:var(--nextui-colors-red600);--nextui-colors-errorSolidHover:var(--nextui-colors-red700);--nextui-colors-errorSolidContrast:var(--nextui-colors-white);--nextui-colors-errorShadow:var(--nextui-colors-red500);--nextui-colors-neutralLight:var(--nextui-colors-gray100);--nextui-colors-neutralLightHover:var(--nextui-colors-gray200);--nextui-colors-neutralLightActive:var(--nextui-colors-gray300);--nextui-colors-neutralLightContrast:var(--nextui-colors-gray800);--nextui-colors-neutral:var(--nextui-colors-gray600);--nextui-colors-neutralBorder:var(--nextui-colors-gray400);--nextui-colors-neutralBorderHover:var(--nextui-colors-gray500);--nextui-colors-neutralSolidHover:var(--nextui-colors-gray600);--nextui-colors-neutralSolidContrast:var(--nextui-colors-white);--nextui-colors-neutralShadow:var(--nextui-colors-gray400);--nextui-colors-gradient:linear-gradient(112deg, var(--nextui-colors-cyan600) -63.59%, var(--nextui-colors-pink600) -20.3%, var(--nextui-colors-blue600) 70.46%);--nextui-colors-accents0:var(--nextui-colors-gray50);--nextui-colors-accents1:var(--nextui-colors-gray100);--nextui-colors-accents2:var(--nextui-colors-gray200);--nextui-colors-accents3:var(--nextui-colors-gray300);--nextui-colors-accents4:var(--nextui-colors-gray400);--nextui-colors-accents5:var(--nextui-colors-gray500);--nextui-colors-accents6:var(--nextui-colors-gray600);--nextui-colors-accents7:var(--nextui-colors-gray700);--nextui-colors-accents8:var(--nextui-colors-gray800);--nextui-colors-accents9:var(--nextui-colors-gray900);--nextui-colors-border:var(--nextui-colors-gray300);--nextui-colors-background:var(--nextui-colors-white);--nextui-colors-foreground:var(--nextui-colors-black);--nextui-colors-backgroundContrast:var(--nextui-colors-white);--nextui-colors-blue50:#EDF5FF;--nextui-colors-blue100:#E1EFFF;--nextui-colors-blue200:#CEE4FE;--nextui-colors-blue300:#B7D5F8;--nextui-colors-blue400:#96C1F2;--nextui-colors-blue500:#5EA2EF;--nextui-colors-blue600:#0072F5;--nextui-colors-blue700:#005FCC;--nextui-colors-blue800:#004799;--nextui-colors-blue900:#00254D;--nextui-colors-purple50:#F7F2FD;--nextui-colors-purple100:#F1E8FB;--nextui-colors-purple200:#EADCF8;--nextui-colors-purple300:#E0CBF5;--nextui-colors-purple400:#D1B1F0;--nextui-colors-purple500:#BC8EE9;--nextui-colors-purple600:#7828C8;--nextui-colors-purple700:#6622AA;--nextui-colors-purple800:#4D1980;--nextui-colors-purple900:#290E44;--nextui-colors-green50:#F1FDF7;--nextui-colors-green100:#E8FCF1;--nextui-colors-green200:#DAFBE8;--nextui-colors-green300:#C8F9DD;--nextui-colors-green400:#ADF5CC;--nextui-colors-green500:#88F1B6;--nextui-colors-green600:#17C964;--nextui-colors-green700:#13A452;--nextui-colors-green800:#108944;--nextui-colors-green900:#06371B;--nextui-colors-yellow50:#FEF9F0;--nextui-colors-yellow100:#FEF5E7;--nextui-colors-yellow200:#FDEFD8;--nextui-colors-yellow300:#FCE7C5;--nextui-colors-yellow400:#FBDBA7;--nextui-colors-yellow500:#F9CB80;--nextui-colors-yellow600:#F5A524;--nextui-colors-yellow700:#B97509;--nextui-colors-yellow800:#925D07;--nextui-colors-ye ``` -------------------------------- ### Initiate Discord OAuth2 Login (JavaScript) Source: https://context7.com/sudhanplayz/discord-musicbot/llms.txt Redirects the user's browser to Discord's OAuth2 authorization URL to initiate the login process. This is the first step in authenticating a user with the Discord Music Bot's web interface. ```javascript // Redirect user to Discord OAuth2 login window.location.href = 'http://localhost:4200/api/login'; // Discord will redirect back to /api/callback after authentication // Successful authentication creates a session and redirects to homepage ``` -------------------------------- ### Authentication Endpoints Source: https://context7.com/sudhanplayz/discord-musicbot/llms.txt Handles user authentication through Discord's OAuth2 flow, including initiating the login process and logging out. ```APIDOC ## GET /api/login ### Description Initiates the Discord OAuth2 authentication flow. This endpoint redirects the user to Discord's authorization page. ### Method GET ### Endpoint /api/login ### Parameters None ### Request Example ```javascript window.location.href = 'http://localhost:4200/api/login'; ``` ## GET /api/logout ### Description Destroys the current user session, effectively logging the user out of the application. ### Method GET ### Endpoint /api/logout ### Parameters None ### Request Example ```javascript const axios = require('axios'); await axios.get('http://localhost:4200/api/logout'); ``` ## GET /api/callback ### Description This is the callback endpoint for Discord OAuth2. It is automatically invoked by Discord after successful user authentication. It processes the authentication response and establishes a user session. This endpoint is typically not called directly by the client. ### Method GET ### Endpoint /api/callback ### Parameters None ### Request Example ```javascript // This endpoint is called automatically by Discord OAuth2 flow. // No direct invocation needed - configured in passport strategy. ``` ### Response #### Success Response (302 Redirect) Upon successful authentication, the user is typically redirected to the homepage or a dashboard page. #### Error Response (Details for error responses would typically be defined by the application's error handling strategy, e.g., 400 Bad Request, 401 Unauthorized, etc.) ``` -------------------------------- ### Register Discord Slash Commands (JavaScript) Source: https://context7.com/sudhanplayz/discord-musicbot/llms.txt Scripts to register slash commands with the Discord API using discord.js and REST. It reads command definitions from the `commands/slash` directory and deploys them either globally or to a specific guild for faster testing. Includes commands for deploying, testing, and removing commands. ```javascript // deploy/deployGlobal.js const { REST } = require('@discordjs/rest'); const { Routes } = require('discord-api-types/v9'); const fs = require('fs'); const path = require('path'); const commands = []; const commandFiles = fs.readdirSync(path.join(__dirname, '..', 'commands', 'slash')); for (const file of commandFiles) { const command = require(path.join(__dirname, '..', 'commands', 'slash', file)); commands.push(command.toJSON()); } const rest = new REST({ version: '9' }).setToken(process.env.token); (async () => { try { console.log('Started refreshing application (/) commands.'); await rest.put( Routes.applicationCommands(process.env.clientId), { body: commands } ); console.log('Successfully reloaded application (/) commands.'); } catch (error) { console.error(error); } })(); ``` -------------------------------- ### Nginx Configuration for Dashboard Source: https://github.com/sudhanplayz/discord-musicbot/wiki/Installation-on-a-Linux-server This Nginx configuration sets up a server block to proxy requests to the Discord Music Bot's dashboard, which typically runs on port 3000. It forwards traffic from a custom domain to the local development server. ```nginx server { listen 80; server_name example.com; location / { proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $http_host; proxy_pass http://127.0.0.1:3000; } } ``` -------------------------------- ### Create Interactive Player Controller Buttons (Discord.js) Source: https://context7.com/sudhanplayz/discord-musicbot/llms.txt Generates interactive buttons for controlling music playback in a Discord channel using discord.js. It creates MessageActionRow and MessageButton components for play/pause, skip, replay, stop, and loop functionalities. The interaction handler processes button clicks to control the music player. ```javascript const { MessageActionRow, MessageButton } = require("discord.js"); // createController method in DiscordMusicBot client.createController = function(guild, player) { return new MessageActionRow().addComponents( new MessageButton() .setStyle("DANGER") .setCustomId(`controller:${guild}:Stop`) .setEmoji("⏹️"), new MessageButton() .setStyle("PRIMARY") .setCustomId(`controller:${guild}:Replay`) .setEmoji("⏮️"), new MessageButton() .setStyle(player.playing ? "PRIMARY" : "DANGER") .setCustomId(`controller:${guild}:PlayAndPause`) .setEmoji(player.playing ? "⏸️" : "▶️"), new MessageButton() .setStyle("PRIMARY") .setCustomId(`controller:${guild}:Next`) .setEmoji("⏭️"), new MessageButton() .setStyle(player.trackRepeat ? "SUCCESS" : "DANGER") .setCustomId(`controller:${guild}:Loop`) .setEmoji(player.trackRepeat ? "🔂" : "🔁") ); }; // Button interaction handling client.on("interactionCreate", async (interaction) => { if (!interaction.isButton()) return; const [type, guild, action] = interaction.customId.split(":"); if (type !== "controller") return; const player = client.manager.players.get(guild); switch(action) { case "Stop": player.destroy(); break; case "Replay": player.seek(0); break; case "PlayAndPause": player.pause(!player.paused); break; case "Next": player.stop(); break; case "Loop": player.setTrackRepeat(!player.trackRepeat); break; } await interaction.deferUpdate(); }); ``` -------------------------------- ### Handle Discord OAuth2 Callback (JavaScript) Source: https://context7.com/sudhanplayz/discord-musicbot/llms.txt This endpoint is automatically invoked by Discord after a user completes the OAuth2 authentication flow. It processes the authentication response, creates a user session, and is typically configured within the Passport.js strategy. ```javascript // This endpoint is called automatically by Discord OAuth2 flow // No direct invocation needed - configured in passport strategy // Callback URL configuration in config.js: // website: "http://localhost:4200", // clientId: "your-bot-client-id", // clientSecret: "your-bot-client-secret", // scopes: ["identify", "guilds", "applications.commands"] ``` -------------------------------- ### Fetch Dashboard Statistics via API (JavaScript) Source: https://context7.com/sudhanplayz/discord-musicbot/llms.txt Retrieves dashboard statistics including commands executed, user count, server count, and songs played. This endpoint requires authentication via a session cookie. It is intended for use by the bot's web dashboard. ```javascript const axios = require('axios'); // Fetch dashboard statistics (requires authentication cookie) const response = await axios.get('http://localhost:4200/api/dashboard', { headers: { 'Cookie': 'connect.sid=your-session-cookie' } }); console.log(response.data); // Output: // { // commandsRan: 1543, // users: 12453, // servers: 38, // songsPlayed: 8921 // } ``` -------------------------------- ### Apply Audio Filters with JavaScript Source: https://context7.com/sudhanplayz/discord-musicbot/llms.txt Applies audio filters and effects to music playback using presets. This command is designed to be used within a Discord bot environment, taking a string option for the desired filter. ```javascript const command = new SlashCommand() .setName("filters") .setDescription("add or remove filters") .addStringOption((option) => option .setName("preset") .setDescription("the preset to add") .setRequired(true) .addChoices( { name: "Nightcore", value: "nightcore" }, { name: "BassBoost", value: "bassboost" }, { name: "Vaporwave", value: "vaporwave" }, { name: "Pop", value: "pop" }, { name: "Soft", value: "soft" }, { name: "Treblebass", value: "treblebass" }, { name: "Eight Dimension", value: "eightD" }, { name: "Karaoke", value: "karaoke" }, { name: "Vibrato", value: "vibrato" }, { name: "Tremolo", value: "tremolo" }, { name: "Reset", value: "off" } ) ) .setRun(async (client, interaction, options) => { const args = interaction.options.getString("preset"); let player = client.manager.players.get(interaction.guild.id); if (args == "nightcore") { player.nightcore = true; } else if (args == "bassboost") { player.bassboost = true; } else if (args == "off") { player.reset(); } return interaction.reply({ embeds: [new MessageEmbed() .setColor(client.config.embedColor) .setDescription("✅ | Filter is now active!")] }); }); ``` -------------------------------- ### Skip Song Command (JavaScript) Source: https://context7.com/sudhanplayz/discord-musicbot/llms.txt Skips the currently playing song and advances to the next track in the queue. It checks the queue state before skipping and informs the user if there are no more songs. ```javascript // In Discord chat: // /skip // Command checks queue state before skipping const command = new SlashCommand() .setName("skip") .setDescription("Skip the current song") .setRun(async (client, interaction, options) => { let player = client.manager.players.get(interaction.guild.id); const song = player.queue.current; const autoQueue = player.get("autoQueue"); if (player.queue[0] == undefined && (!autoQueue || autoQueue === false)) { return interaction.reply({ embeds: [new MessageEmbed() .setColor("RED") .setDescription(`There is nothing after [${song.title}](${song.uri}) in the queue.`)] }); } player.queue.previous = player.queue.current; player.stop(); interaction.reply({ embeds: [new MessageEmbed() .setColor(client.config.embedColor) .setDescription("✅ | **Skipped!**")] }); }); ``` -------------------------------- ### Loop Track Command (JavaScript) Source: https://context7.com/sudhanplayz/discord-musicbot/llms.txt Toggles the loop mode for the currently playing track on or off. It checks if a player is active and updates the player's track repeat status, confirming the change to the user. ```javascript // In Discord chat: // /loop // Command toggles track repeat on/off const command = new SlashCommand() .setName("loop") .setDescription("Loops the current song") .setRun(async (client, interaction, options) => { let player = client.manager.players.get(interaction.guild.id); if (!player) { return interaction.reply({ embeds: [new MessageEmbed() .setColor("RED") .setDescription("Nothing is playing right now.")] }); } player.setTrackRepeat(!player.trackRepeat); const trackRepeat = player.trackRepeat ? "enabled" : "disabled"; interaction.reply({ embeds: [new MessageEmbed() .setColor(client.config.embedColor) .setDescription(`👍 | **Loop has been `${trackRepeat}`**`)] }); }); ``` -------------------------------- ### Logout User via API (JavaScript) Source: https://context7.com/sudhanplayz/discord-musicbot/llms.txt Logs out the currently authenticated user by destroying their session on the server. After calling this endpoint, the user will be redirected to the homepage without an active session. ```javascript const axios = require('axios'); // Logout endpoint destroys session await axios.get('http://localhost:4200/api/logout'); // User is redirected to homepage with session cleared ``` -------------------------------- ### NextUI CSS Color Variables Definitions Source: https://github.com/sudhanplayz/discord-musicbot/blob/v5/dashboard/out/404.html This snippet defines a comprehensive set of CSS custom properties (variables) for NextUI's color palette. These variables cover primary, secondary, status (success, warning, error), neutral, and accent colors, along with a gradient definition. They are intended for use in styling NextUI components. ```css extui-colors-secondaryBorder:var(--nextui-colors-purple500); --nextui-colors-secondaryBorderHover:var(--nextui-colors-purple600); --nextui-colors-secondarySolidHover:var(--nextui-colors-purple700); --nextui-colors-secondarySolidContrast:var(--nextui-colors-white); --nextui-colors-secondaryShadow:var(--nextui-colors-purple500); --nextui-colors-successLight:var(--nextui-colors-green200); --nextui-colors-successLightHover:var(--nextui-colors-green300); --nextui-colors-successLightActive:var(--nextui-colors-green400); --nextui-colors-successLightContrast:var(--nextui-colors-green700); --nextui-colors-success:var(--nextui-colors-green600); --nextui-colors-successBorder:var(--nextui-colors-green500); --nextui-colors-successBorderHover:var(--nextui-colors-green600); --nextui-colors-successSolidHover:var(--nextui-colors-green700); --nextui-colors-successSolidContrast:var(--nextui-colors-white); --nextui-colors-successShadow:var(--nextui-colors-green500); --nextui-colors-warningLight:var(--nextui-colors-yellow200); --nextui-colors-warningLightHover:var(--nextui-colors-yellow300); --nextui-colors-warningLightActive:var(--nextui-colors-yellow400); --nextui-colors-warningLightContrast:var(--nextui-colors-yellow700); --nextui-colors-warning:var(--nextui-colors-yellow600); --nextui-colors-warningBorder:var(--nextui-colors-yellow500); --nextui-colors-warningBorderHover:var(--nextui-colors-yellow600); --nextui-colors-warningSolidHover:var(--nextui-colors-yellow700); --nextui-colors-warningSolidContrast:var(--nextui-colors-white); --nextui-colors-warningShadow:var(--nextui-colors-yellow500); --nextui-colors-errorLight:var(--nextui-colors-red200); --nextui-colors-errorLightHover:var(--nextui-colors-red300); --nextui-colors-errorLightActive:var(--nextui-colors-red400); --nextui-colors-errorLightContrast:var(--nextui-colors-red600); --nextui-colors-error:var(--nextui-colors-red600); --nextui-colors-errorBorder:var(--nextui-colors-red500); --nextui-colors-errorBorderHover:var(--nextui-colors-red600); --nextui-colors-errorSolidHover:var(--nextui-colors-red700); --nextui-colors-errorSolidContrast:var(--nextui-colors-white); --nextui-colors-errorShadow:var(--nextui-colors-red500); --nextui-colors-neutralLight:var(--nextui-colors-gray100); --nextui-colors-neutralLightHover:var(--nextui-colors-gray200); --nextui-colors-neutralLightActive:var(--nextui-colors-gray300); --nextui-colors-neutralLightContrast:var(--nextui-colors-gray800); --nextui-colors-neutral:var(--nextui-colors-gray600); --nextui-colors-neutralBorder:var(--nextui-colors-gray400); --nextui-colors-neutralBorderHover:var(--nextui-colors-gray500); --nextui-colors-neutralSolidHover:var(--nextui-colors-gray600); --nextui-colors-neutralSolidContrast:var(--nextui-colors-white); --nextui-colors-neutralShadow:var(--nextui-colors-gray400); --nextui-colors-gradient:linear-gradient(112deg, var(--nextui-colors-cyan600) -63.59%, var(--nextui-colors-pink600) -20.3%, var(--nextui-colors-blue600) 70.46%); --nextui-colors-accents0:var(--nextui-colors-gray50); --nextui-colors-accents1:var(--nextui-colors-gray100); --nextui-colors-accents2:var(--nextui-colors-gray200); --nextui-colors-accents3:var(--nextui-colors-gray300); --nextui-colors-accents4:var(--nextui-colors-gray400); --nextui-colors-accents5:var(--nextui-colors-gray500); --nextui-colors-accents6:var(--nextui-colors-gray600); --nextui-colors-accents7:var(--nextui-colors-gray700); --nextui-colors-accents8:var(--nextui-colors-gray800); --nextui-colors-accents9:var(--nextui-colors-gray900); --nextui-colors-border:var(--nextui-colors-gray300); --nextui-colors-background:var(--nextui-colors-white); --nextui-colors-foreground:var(--nextui-colors-black); --nextui-colors-backgroundContrast:var(--nextui-colors-white); --nextui-colors-blue50:#EDF5FF; --nextui-colors-blue100:#E1EFFF; --nextui-colors-blue200:#CEE4FE; --nextui-colors-blue300:#B7D5F8; --nextui-colors-blue400:#96C1F2; --nextui-colors-blue500:#5EA2EF; --nextui-colors-blue600:#0072F5; --nextui-colors-blue700:#005FCC; --nextui-colors-blue800:#004799; --nextui-colors-blue900:#00254D; --nextui-colors-purple50:#F7F2FD; --nextui-colors-purple100:#F1E8FB; --nextui-colors-purple200:#EADCF8; --nextui-colors-purple300:#E0CBF5; --nextui-colors-purple400:#D1B1F0; --nextui-colors-purple500:#BC8EE9; --nextui-colors-purple600:#7828C8; --nextui-colors-purple700:#6622AA; --nextui-colors-purple800:#4D1980; --nextui-colors-purple900:#290E44; --nextui-colors-green50:#F1FDF7; --nextui-colors-green100:#E8FCF1; --nextui-colors-green200:#DAFBE8; --nextui-colors-green300:#C8F9DD; --nextui-colors-green400:#ADF5CC; --nextui-colors-green500:#88F1B6; --nextui-colors-green600:#17C964; --nextui-colors-green700:#13A452; --nextui-colors-green800:#108944; --nextui-colors-green900:#06371B; --nextui-colors-yellow50:#FEF9F0; --nextui-colors-yellow100:#FEF5E7; --nextui-colors-yellow200:#FDEFD8; --nextui-colors-yellow300:#FCE7C5; --nextui-colors-yellow400:#FBDBA7; --nextui-colors-yellow500:#F9CB80; --nextui-colors-yellow600:#F5A524; --nextui-colors-yellow700:#B97509; --nextui-colors-yellow800:#925D07; ``` -------------------------------- ### Pause Music Command (JavaScript) Source: https://context7.com/sudhanplayz/discord-musicbot/llms.txt Pauses the currently playing track in a Discord voice channel. It validates the voice channel and player state, and returns an error if nothing is playing or if the track is already paused. ```javascript // In Discord chat: // /pause // Command validates voice channel, checks player state const command = new SlashCommand() .setName("pause") .setDescription("Pauses the current playing track") .setRun(async (client, interaction, options) => { let player = client.manager.players.get(interaction.guild.id); if (!player) { return interaction.reply({ embeds: [new MessageEmbed() .setColor("RED") .setDescription("Nothing is playing.")] }); } if (player.paused) { return interaction.reply({ embeds: [new MessageEmbed() .setColor("RED") .setDescription("Current playing track is already paused!")] }); } player.pause(true); return interaction.reply({ embeds: [new MessageEmbed() .setColor(client.config.embedColor) .setDescription("⏸ | **Paused!**")] }); }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.