Code Monkey home page Code Monkey logo

Comments (8)

RaFaTEOLI avatar RaFaTEOLI commented on August 26, 2024 1

Hello, it appears @SushiBtw gave up on this project, so i've forked it and published to npm with many bug fixes and new features.

I am working to fix this bug there, let me know if you find anything else that might help me debug it, my discord is: RaFaTEOLI.

Repo: https://github.com/RaFaTEOLI/discord-music-player
Package: https://www.npmjs.com/package/@rafateoli/discord-music-player

from discord-music-player.

ChubbyStewwa avatar ChubbyStewwa commented on August 26, 2024 1

I just tried it with a new blank project to avoid problems from other code and just added the needed stuff and still get the error

Here the code

const { Client, GatewayIntentBits } = require("discord.js");

const client = new Client({
    intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildVoiceStates]
});
const settings = {
    prefix: '!',
    token: '<token>'
};

const { Player } = require("@rafateoli/discord-music-player");
const player = new Player(client);

client.player = player;

client.on("ready", () => {
    console.log("I am ready to Play with DMP 🎶");
});

client.player
    .on('songAdd', (queue, song) =>
        console.log(`Song ${song} was added to the queue.`))
    .on('playlistAdd', (queue, playlist) =>
        console.log(`Playlist ${playlist} with ${playlist.songs.length} was added to the queue.`))
    .on('queueDestroyed', (queue) =>
        console.log(`The queue was destroyed.`)) 
    .on('queueEnd', (queue) =>
        console.log(`The queue has ended.`))
    .on('error', (error, queue) => {
        console.log(`Error: ${error} in ${queue.guild.name}`);
    })

client.on('messageCreate', async (message) => {
    const args = message.content.slice(settings.prefix.length).trim().split(/ +/g);
    const command = args.shift();
    let guildQueue = client.player.getQueue(message.guild.id);

    if (command === 'play') {
        let queue = client.player.createQueue(message.guild.id);
        await queue.join(message.member.voice.channel);
        let song = await queue.play(args.join(' ')).catch(err => {
            console.log(err);
            if (!guildQueue)
                queue.stop();
        });
    }

    if (command === 'playlist') {
        let queue = client.player.createQueue(message.guild.id);
        await queue.join(message.member.voice.channel);
        let song = await queue.playlist(args.join(' ')).catch(err => {
            console.log(err);
            if (!guildQueue)
                queue.stop();
        });
    }
})

client.login(settings.token);

from discord-music-player.

RaFaTEOLI avatar RaFaTEOLI commented on August 26, 2024

Reference: fent/node-ytdl-core#1295

from discord-music-player.

RaFaTEOLI avatar RaFaTEOLI commented on August 26, 2024

@ChubbyStewwa fix pushed to https://github.com/RaFaTEOLI/discord-music-player
Please try again and let me know how it goes.

from discord-music-player.

ChubbyStewwa avatar ChubbyStewwa commented on August 26, 2024

@RaFaTEOLI it's still not working, now I can't even start the bot

here the error

/<path>/node_modules/@rafateoli/discord-ytdl-core/index.ts:1
import ytdl, { downloadOptions } from '@distube/ytdl-core';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:77:18)
    at wrapSafe (node:internal/modules/cjs/loader:1288:20)
    at Module._compile (node:internal/modules/cjs/loader:1340:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/<path>/node_modules/@rafateoli/discord-music-player/dist/managers/Queue.js:9:45)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)

Node.js v20.11.0

from discord-music-player.

RaFaTEOLI avatar RaFaTEOLI commented on August 26, 2024

That is weird, I will take a look at that later, however it works very well here for me, in case you wanna check it out: https://github.com/RaFaTEOLI/discord-bot-player

from discord-music-player.

RaFaTEOLI avatar RaFaTEOLI commented on August 26, 2024

Hey I haven't been able to reproduce your error, can you send me how your package.json looks like?

from discord-music-player.

ChubbyStewwa avatar ChubbyStewwa commented on August 26, 2024

Sure, here it is
it's just the one for the test bot I set up but get same error

{
  "name": "test",
  "version": "1.0.0",
  "description": "Testing Discord Music Player",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@discordjs/opus": "^0.9.0",
    "@rafateoli/discord-music-player": "^9.2.7",
    "discord.js": "^14.15.3"
  }
}

Here is the error again

<PATH>\MusicTest\node_modules\@rafateoli\discord-ytdl-core\index.ts:1
import ytdl, { downloadOptions } from '@distube/ytdl-core';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:128:18)
    at wrapSafe (node:internal/modules/cjs/loader:1280:20)
    at Module._compile (node:internal/modules/cjs/loader:1332:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
    at Module.load (node:internal/modules/cjs/loader:1206:32)
    at Module._load (node:internal/modules/cjs/loader:1022:12)
    at Module.require (node:internal/modules/cjs/loader:1231:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (<PATH>\MusicTest\node_modules\@rafateoli\discord-music-player\dist\managers\Queue.js:9:45)
    at Module._compile (node:internal/modules/cjs/loader:1369:14)

Node.js v20.12.2

from discord-music-player.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.