[BUG] Status code: 403 when playing any song
Opened this issue · 13 comments
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:
- Use
/play
command with song link or title. - 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
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
Reference: fent/node-ytdl-core#1295
@ChubbyStewwa fix pushed to https://github.com/RaFaTEOLI/discord-music-player
Please try again and let me know how it goes.
@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
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
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);
Hey I haven't been able to reproduce your error, can you send me how your package.json
looks like?
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
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
I was able to fix the problem.
Switched from tsc
and ts-node
to tsx
and everything worker.
Nice, yes same here, mine is running with tsx
and it runs fine, thank you for helping them out.
I was able to fix the problem. Switched from
tsc
andts-node
totsx
and everything worker.
Thanks! This also fixed the issue for me. Seems to be working now!
I was able to fix the problem. Switched from
tsc
andts-node
totsx
and everything worker.
how did you manage to switch?
because i'm very clueless as to how to do this task