Music Player

index.js
// Imports
const { Client, commandHandler, playerHandler } = require("djsplus")

// Client
let client = new Client()

// Config
client.config.prefix = "?" // Command Prefix

// Command Handler
commandHandler(client, __dirname)

// Music Player
playerHandler(client)

// Login
client.login("Your bot token")

Inside our cmds directory we will create a directory called "music". Inside the directory make a file called play.js

play.js
module.exports = {
    name: "play", // Command Name
    module: "music", // Must be a valid key to a module.
    execute: (client, message, args) => {
        if(!args[0]) {
            message.channel.send("Please specify a song to play")
            return
        }
        
        client.player.play(message, args[0])
        // By default, the message "Now playing (TRAC TITLE)"
        // is shown, so no confirmation message needed.
    }
}

Last updated

Was this helpful?