Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Status code: 403 when playing any song #332

Open
ChubbyStewwa opened this issue Jul 14, 2024 · 14 comments
Open

[BUG] Status code: 403 when playing any song #332

ChubbyStewwa opened this issue Jul 14, 2024 · 14 comments
Assignees
Labels

Comments

@ChubbyStewwa
Copy link

Bug Description
When I want to play a song, no matter if with link or with title I get the error 403

Reproduction Steps
Steps to reproduce the behavior:

  1. Use /play command with song link or title.
  2. Observe the result.

Expected Result
It is supposed to play the song

Attachments
Here the full error message

Error [ERR_UNHANDLED_ERROR]: Unhandled error. ('Status code: 403')
    at Player.emit (node:events:507:17)
    at StreamConnection.<anonymous> (/home/eevee/EeveeBot/node_modules/discord-music-player/dist/managers/Queue.js:184:47)
    at StreamConnection.emit (node:events:518:28)
    at AudioPlayer.<anonymous> (/home/eevee/EeveeBot/node_modules/discord-music-player/dist/voice/StreamConnection.js:91:18)
    at AudioPlayer.emit (node:events:518:28)
    at Encoder.onStreamError (/home/eevee/EeveeBot/node_modules/discord-music-player/node_modules/@discordjs/voice/dist/index.js:954:14)
    at Object.onceWrapper (node:events:633:26)
    at Encoder.emit (node:events:530:35)
    at emitErrorNT (node:internal/streams/destroy:169:8)
    at emitErrorCloseNT (node:internal/streams/destroy:128:3) {
  code: 'ERR_UNHANDLED_ERROR',
  context: 'Status code: 403'
}

Versioning:

  • OS: Ubuntu 22.04.3 LTS
  • Node Version 20.11.0
  • Module Version 9.1.1
@RaFaTEOLI
Copy link

RaFaTEOLI commented Jul 24, 2024

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

@RaFaTEOLI
Copy link

Reference: fent/node-ytdl-core#1295

@RaFaTEOLI
Copy link

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

@ChubbyStewwa
Copy link
Author

@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

@RaFaTEOLI
Copy link

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

@ChubbyStewwa
Copy link
Author

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);

@RaFaTEOLI
Copy link

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

@ChubbyStewwa
Copy link
Author

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

@wildermason
Copy link

Have gotten around to testing this on my end now as well, and i can confirm I'm also getting the same error on my end:

/workspaces/DiscordJS-Music-Bot/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:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1176:20)
    at Module._compile (node:internal/modules/cjs/loader:1218:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/workspaces/DiscordJS-Music-Bot/node_modules/@rafateoli/discord-music-player/dist/managers/Queue.js:9:45)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)

Node.js v18.16.0

@dgranosa
Copy link

dgranosa commented Sep 7, 2024

I was able to fix the problem.
Switched from tsc and ts-node to tsx and everything worker.

@RaFaTEOLI
Copy link

Nice, yes same here, mine is running with tsx and it runs fine, thank you for helping them out.

@wildermason
Copy link

I was able to fix the problem. Switched from tsc and ts-node to tsx and everything worker.

Thanks! This also fixed the issue for me. Seems to be working now!

@BDT-4248
Copy link

I was able to fix the problem. Switched from tsc and ts-node to tsx and everything worker.

how did you manage to switch?
because i'm very clueless as to how to do this task

@EclipseGame18
Copy link

I was able to fix the problem. Switched from tsc and ts-node to tsx and everything worker.

how did you manage to switch? because i'm very clueless as to how to do this task

In your package.json file in the "scripts" field replace node index.js with tsx index.js.

  "scripts": {
    "start": "tsx index.js"
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants