Skip to content

No longer works #20

Description

@Beastskyler

I have finally started to get back into coding a found out this no longer works.

const commando = require('discord.js-commando');
const ytlist = require('youtube-playlist');
var fs = require('fs');
var path = require('path');
const { exec } = require("child_process");

class PlaylistChannelCommand extends commando.Command {
    constructor(client) {
        super(client, {
            name: 'playlist',
            group: 'music',
            memberName: 'playlist',
            description: 'Adds playlist to the random music bot',
            args: [
                {
                    key: 'link',
                    prompt: 'What playlist do you want to add?',
                    type: 'string'
                }
            ]
        });
    }

    async run(message, { link }) {

        function restart() {
            exec("pm2 restart music", (error, stdout, stderr) => {
                if (error) {
                    console.log(`error: ${error.message}`);
                }
                if (stderr) {
                    console.log(`stderr: ${stderr}`);
                }
                console.log(`stdout: ${stdout}`);
            });
        }

        var pathToFile = path.resolve(__dirname, "../../queue.txt");

        ytlist(link, 'url').then(res => {
            let pls = res.data.playlist.toString().split(',').join('\n');
            fs.appendFile(pathToFile, "\n" + pls, 'utf8',
                function (err) {
                    if (err) throw err;
                    console.log("Data is appended to file successfully.");
                    restart();
                    message.channel.send("Success, " + res.data.playlist.length + ' songs added!');
                });
        });
    }
}

module.exports = PlaylistChannelCommand;

Running this command adds no urls. I am a little more comfortable coding and would like to try and help, however, I don't know how much help I could be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions