Closed RisedSky closed 3 years ago
You should handle player errors, please check the guide for more information.
Once you log them, you'll most likely get a hint at what's going on.
You should handle player errors, please check the guide for more information.
Once you log them, you'll most likely get a hint at what's going on.
I'm already handing player errors using this code :
player.on("stateChange", async (oldState, newState) => {
if (oldState.status == "playing" && newState.status == "idle") {
console.log("Finished playing the song")
if (sentMessage.deletable) await sentMessage.delete();
/*
cmdInteraction.channel.send({
content: "Finished Playing"
}).then(m => m.delete({ timeout: 10 * 1000 }))
*/
await connection.disconnect();
} else if (oldState.status == "playing" && VoiceConnectionStatus.Disconnected) {
console.log("Kicked out ?")
if (sentMessage.deletable) await sentMessage.delete();
await player.stop();
cmdInteraction.channel.send({
content: "Left the channel due to a kick."
}).then(m => util.deleteMyMessage(m, 30))
} else if (oldState.status == "playing" && newState.status == "idle") {
console.log("Detected a possible crash")
}
})
is this OK ? Or i should handle more ?
Not that bit, the player.on("error", (error) => {})
one.
Not that bit, the
player.on("error", (error) => {})
one.
I put this player.on("State... in my commandInteraction file handler, is this OK or i should put this part of code somewhere else ?
Also, how can i retrieve the player of a guild ? (i'm searching to pause it, but i didn't find to :( )
Sorry if i'm disturbing you, but i was using v8/v9 until i re-code a new Discord bot ^^"
That's not handling [the 100% of the] errors, please add the following code (of feel free to customise it a little as long as you log them):
player.on("error", console.error);
Okay so it happens again, here are the full log when playing and crashing :
I'm connected
『🔊』Salon bot
{name: 'song', type: 'STRING', value: 'https://www.youtube.com/watch?v=BwL0P0kR1Mc'}
String: https://www.youtube.com/watch?v=BwL0P0kR1Mc
(2) ['?v=BwL0P0kR1Mc', 'BwL0P0kR1Mc', index: 29, input: 'https://www.youtube.com/watch?v=BwL0P0kR1Mc', groups: undefined]
Matches: ?v=BwL0P0kR1Mc,BwL0P0kR1Mc
BwL0P0kR1Mc
video=BwL0P0kR1Mc
BwL0P0kR1Mc
DEBUG Volume:
AudioResource {playbackDuration: 0, started: false, silenceRemaining: -1, edges: Array(2), playStream: OggDemuxer, …}
58 minutes, 28 secondes.
-- DEBUG --
Error: aborted
at connResetException (/home/vscode/RisedSky/github/discordAPITest/lib/internal/errors.js:683:14)
at TLSSocket.socketCloseListener (/home/vscode/RisedSky/github/discordAPITest/lib/_http_client.js:407:19)
at TLSSocket.emit (/home/vscode/RisedSky/github/discordAPITest/lib/events.js:406:35)
at /home/vscode/RisedSky/github/discordAPITest/lib/net.js:661:12
at TCP.done (/home/vscode/RisedSky/github/discordAPITest/lib/_tls_wrap.js:580:7)
at TCP.callbackTrampoline (node:internal/async_hooks:130:17) {resource: AudioResource, name: 'Error', stack: 'Error: aborted
at connResetException (nod…Trampoline (node:internal/async_hooks:130:17)', message: 'aborted'}
arg0: Error: aborted
at connResetException (node:internal/errors:683:14)
at TLSSocket.socketCloseListener (node:_http_client:407:19)
at TLSSocket.emit (node:events:406:35)
at node:net:661:12
at TCP.done (node:_tls_wrap:580:7)
at TCP.callbackTrampoline (node:internal/async_hooks:130:17) {resource: AudioResource, name: 'Error', stack: 'Error: aborted
at connResetException (nod…Trampoline (node:internal/async_hooks:130:17)', message: 'aborted'}
message: 'aborted'
name: 'Error'
resource: AudioResource {playbackDuration: 487720, started: true, silenceRemaining: -1, edges: Array(2), playStream: OggDemuxer, …}
stack: 'Error: aborted\n at connResetException (node:internal/errors:683:14)\n at TLSSocket.socketCloseListener (node:_http_client:407:19)\n at TLSSocket.emit (node:events:406:35)\n at node:net:661:12\n at TCP.done (node:_tls_wrap:580:7)\n at TCP.callbackTrampoline (node:internal/async_hooks:130:17)'
__proto__: Error
emit @ events:394:28
onStreamError @ /home/vscode/RisedSky/github/discordAPITest/node_modules/@discordjs/voice/src/audio/AudioPlayer.ts:349:10
onceWrapper @ events:514:26
emit @ events:406:35
emitErrorNT @ internal/streams/destroy:193:8
emitErrorCloseNT @ internal/streams/destroy:158:3
processTicksAndRejections @ internal/process/task_queues:83:21
◀ TickObject ▶
init @ internal/inspector_async_hook:25:19
emitInitNative @ internal/async_hooks:203:43
emitInitScript @ internal/async_hooks:472:3
nextTick @ internal/process/task_queues:133:5
<anonymous> @ internal/streams/destroy:92:15
_destroy @ /home/vscode/RisedSky/github/discordAPITest/node_modules/prism-media/src/opus/OggDemuxer.js:110:17
_destroy @ internal/streams/destroy:72:23
destroy @ internal/streams/destroy:64:5
destroyer @ internal/streams/destroy:370:59
<anonymous> @ internal/streams/pipeline:71:17
finish @ internal/streams/pipeline:157:23
<anonymous> @ internal/util:418:5
<anonymous> @ internal/streams/pipeline:72:5
finish @ internal/streams/pipeline:157:23
<anonymous> @ internal/util:418:5
<anonymous> @ internal/streams/pipeline:64:7
<anonymous> @ internal/util:418:5
onerror @ internal/streams/end-of-stream:128:14
emit @ events:406:35
emit @ events:406:35
onError @ /home/vscode/RisedSky/github/discordAPITest/node_modules/miniget/src/index.ts:200:16
emit @ events:394:28
emitErrorNT @ internal/streams/destroy:193:8
emitErrorCloseNT @ internal/streams/destroy:158:3
processTicksAndRejections @ internal/process/task_queues:83:21
◀ TickObject ▶
init @ internal/inspector_async_hook:25:19
emitInitNative @ internal/async_hooks:203:43
emitInitScript @ internal/async_hooks:472:3
nextTick @ internal/process/task_queues:133:5
<anonymous> @ internal/streams/destroy:92:15
onError @ _http_incoming:380:5
_destroy @ _http_incoming:194:5
_destroy @ internal/streams/destroy:72:23
destroy @ internal/streams/destroy:64:5
socketCloseListener @ _http_client:407:11
emit @ events:406:35
<anonymous> @ net:661:12
done @ _tls_wrap:580:7
callbackTrampoline @ internal/async_hooks:130:17
◀ TCPWRAP ▶
init @ internal/inspector_async_hook:25:19
emitInitNative @ internal/async_hooks:203:43
TLSSocket._wrapHandle @ _tls_wrap:604:7
TLSSocket @ _tls_wrap:515:18
connect @ _tls_wrap:1615:19
createConnection @ https:147:22
createSocket @ _http_agent:341:26
addRequest @ _http_agent:292:10
ClientRequest @ _http_client:305:16
request @ https:357:10
doDownload @ /home/vscode/RisedSky/github/discordAPITest/node_modules/miniget/src/index.ts:226:29
processTicksAndRejections @ internal/process/task_queues:78:11
◀ TickObject ▶
init @ internal/inspector_async_hook:25:19
emitInitNative @ internal/async_hooks:203:43
emitInitScript @ internal/async_hooks:472:3
nextTick @ internal/process/task_queues:133:5
Miniget @ /home/vscode/RisedSky/github/discordAPITest/node_modules/miniget/src/index.ts:332:11
getNextChunk @ /home/vscode/RisedSky/github/discordAPITest/node_modules/ytdl-core/lib/index.js:147:15
downloadFromInfoCallback @ /home/vscode/RisedSky/github/discordAPITest/node_modules/ytdl-core/lib/index.js:159:7
<anonymous> @ /home/vscode/RisedSky/github/discordAPITest/node_modules/ytdl-core/lib/index.js:20:5
processTicksAndRejections @ internal/process/task_queues:96:5
◀ Promise.then ▶
ytdl @ /home/vscode/RisedSky/github/discordAPITest/node_modules/ytdl-core/lib/index.js:19:31
playSong @ /home/vscode/RisedSky/github/discordAPITest/util.js:237:52
execute @ /home/vscode/RisedSky/github/discordAPITest/interactions/commandInteraction.js:386:18
processTicksAndRejections @ internal/process/task_queues:96:5
◀ async function ▶
<anonymous> @ /home/vscode/RisedSky/github/discordAPITest/index.js:35:62
emit @ events:406:35
handle @ /home/vscode/RisedSky/github/discordAPITest/node_modules/discord.js/src/client/actions/InteractionCreate.js:45:12
module.exports @ /home/vscode/RisedSky/github/discordAPITest/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36
handlePacket @ /home/vscode/RisedSky/github/discordAPITest/node_modules/discord.js/src/client/websocket/WebSocketManager.js:345:31
onPacket @ /home/vscode/RisedSky/github/discordAPITest/node_modules/discord.js/src/client/websocket/WebSocketShard.js:443:22
onMessage @ /home/vscode/RisedSky/github/discordAPITest/node_modules/discord.js/src/client/websocket/WebSocketShard.js:300:10
onMessage @ /home/vscode/RisedSky/github/discordAPITest/node_modules/ws/lib/event-target.js:132:16
emit @ events:394:28
receiverOnMessage @ /home/vscode/RisedSky/github/discordAPITest/node_modules/ws/lib/websocket.js:833:20
emit @ events:394:28
dataMessage @ /home/vscode/RisedSky/github/discordAPITest/node_modules/ws/lib/receiver.js:517:14
getData @ /home/vscode/RisedSky/github/discordAPITest/node_modules/ws/lib/receiver.js:435:17
startLoop @ /home/vscode/RisedSky/github/discordAPITest/node_modules/ws/lib/receiver.js:143:22
_write @ /home/vscode/RisedSky/github/discordAPITest/node_modules/ws/lib/receiver.js:78:10
writeOrBuffer @ internal/streams/writable:389:12
_write @ internal/streams/writable:330:10
Writable.write @ internal/streams/writable:334:10
socketOnData @ /home/vscode/RisedSky/github/discordAPITest/node_modules/ws/lib/websocket.js:908:35
emit @ events:394:28
addChunk @ internal/streams/readable:312:12
readableAddChunk @ internal/streams/readable:287:9
Readable.push @ internal/streams/readable:226:10
onStreamRead @ internal/stream_base_commons:190:23
callbackTrampoline @ internal/async_hooks:130:17
◀ TLSWRAP ▶
init @ internal/inspector_async_hook:25:19
emitInitNative @ internal/async_hooks:203:43
TLSSocket._wrapHandle @ _tls_wrap:616:24
TLSSocket @ _tls_wrap:515:18
connect @ _tls_wrap:1615:19
tlsConnect @ /home/vscode/RisedSky/github/discordAPITest/node_modules/ws/lib/websocket.js:700:14
ClientRequest @ _http_client:320:45
request @ https:357:10
get @ https:391:15
initAsClient @ /home/vscode/RisedSky/github/discordAPITest/node_modules/ws/lib/websocket.js:566:31
WebSocket @ /home/vscode/RisedSky/github/discordAPITest/node_modules/ws/lib/websocket.js:71:7
exports.create @ /home/vscode/RisedSky/github/discordAPITest/node_modules/discord.js/src/WebSocket.js:34:14
<anonymous> @ /home/vscode/RisedSky/github/discordAPITest/node_modules/discord.js/src/client/websocket/WebSocketShard.js:255:47
connect @ /home/vscode/RisedSky/github/discordAPITest/node_modules/discord.js/src/client/websocket/WebSocketShard.js:183:12
createShards @ /home/vscode/RisedSky/github/discordAPITest/node_modules/discord.js/src/client/websocket/WebSocketManager.js:241:19
createShards @ /home/vscode/RisedSky/github/discordAPITest/node_modules/discord.js/src/client/websocket/WebSocketManager.js:257:19
◀ async function ▶
connect @ /home/vscode/RisedSky/github/discordAPITest/node_modules/discord.js/src/client/websocket/WebSocketManager.js:156:17
processTicksAndRejections @ internal/process/task_queues:96:5
◀ async function ▶
login @ /home/vscode/RisedSky/github/discordAPITest/node_modules/discord.js/src/client/Client.js:228:21
processTicksAndRejections @ internal/process/task_queues:96:5
◀ async function ▶
<anonymous> @ /home/vscode/RisedSky/github/discordAPITest/index.js:12:8
Module._compile @ internal/modules/cjs/loader:1109:14
Module._extensions..js @ internal/modules/cjs/loader:1138:10
Module.load @ internal/modules/cjs/loader:989:32
Module._load @ internal/modules/cjs/loader:829:14
executeUserEntryPoint @ internal/modules/run_main:76:12
<anonymous> @ internal/main/run_main_module:17:47
Finished playing the song
The error only :
Error: aborted
at connResetException (/home/vscode/RisedSky/github/discordAPITest/lib/internal/errors.js:683:14)
at TLSSocket.socketCloseListener (/home/vscode/RisedSky/github/discordAPITest/lib/_http_client.js:407:19)
at TLSSocket.emit (/home/vscode/RisedSky/github/discordAPITest/lib/events.js:406:35)
at /home/vscode/RisedSky/github/discordAPITest/lib/net.js:661:12
at TCP.done (/home/vscode/RisedSky/github/discordAPITest/lib/_tls_wrap.js:580:7)
at TCP.callbackTrampoline (node:internal/async_hooks:130:17) {resource: AudioResource, name: 'Error', stack: 'Error: aborted
at connResetException (nod…Trampoline (node:internal/async_hooks:130:17)', message: 'aborted'}
This error is from ytdl-core, not us. We recommend using youtube-dl
instead (you can take a look at our music bot example to see it in action)
This error is from ytdl-core, not us. We recommend using
youtube-dl
instead (you can take a look at our music bot example to see it in action)
Thanks for this answer, i'll try this, if it occurs again, i'll reopen this issue :)
Please describe the problem you are having in as much detail as possible: When i'm playing my music in the bot, after like 4 minutes of the song. It happens when the video / music is longer than 3 minutes / 4 minutes
Include a reproducible code sample here, if possible: Play this song : https://www.youtube.com/watch?v=BwL0P0kR1Mc Wait 4 minutes in the channel (or 5) See that it crash The exact error is Uncaught Error: aborted
In a slashCommand event i sent the command into my file, using "/play"
Further details: ├── @discordjs/opus@0.5.3 ├── @discordjs/voice@0.5.1 ├── axios@0.21.1 ├── colors@1.4.0 ├── discord.js@13.0.0-dev (git+ssh://git@github.com/discordjs/discord.js.git#b15d825bb3acdf432b94d8413a7a964ccc8734bc) ├── fs@0.0.1-security ├── libsodium-wrappers@0.7.9 ├── moment@2.29.1 ├── ms@2.1.3 ├── youtube-dl-exec@1.2.4 └── ytdl-core@4.8.3
Relevant client options: