miawue
miawue
DIAdiscord.js - Imagine an app
Created by miawue on 12/30/2023 in #djs-voice
Voice connection dropping after 3-5 min with ECONNRESET error
Error: node:events:495 throw er; // Unhandled 'error' event ^ Error: read ECONNRESET at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20) Emitted 'error' event on BodyReadable instance at: at BodyReadable.emit (X:\Code\DiscordBotinok\node_modules\undici\lib\api\readable.js:71:18) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { errno: -4077, code: 'ECONNRESET', syscall: 'read' } Function that plays music:
const playFunc = async (player, interaction) => {
player.extractors.register(YouTubeExtractor);
const channel = interaction.member.voice.channel;
if (!channel) return interaction.reply('You need to be in voice channel'); // You need to be in voice channel
const query = interaction.options.getString('url', true);

// await interaction.deferReply();

try {
const { track } = await player.play(channel, query, {
nodeOptions: {
// nodeOptions are the options for guild node (aka your queue in simple word)
metadata: interaction // we can access this metadata object using queue.metadata later on
}
});

return await interaction.followUp(`**${track.title}** is playing!`);
} catch (e) {
return await interaction.followUp(`Somthing went wrong: ${e}`);
}
}
const playFunc = async (player, interaction) => {
player.extractors.register(YouTubeExtractor);
const channel = interaction.member.voice.channel;
if (!channel) return interaction.reply('You need to be in voice channel'); // You need to be in voice channel
const query = interaction.options.getString('url', true);

// await interaction.deferReply();

try {
const { track } = await player.play(channel, query, {
nodeOptions: {
// nodeOptions are the options for guild node (aka your queue in simple word)
metadata: interaction // we can access this metadata object using queue.metadata later on
}
});

return await interaction.followUp(`**${track.title}** is playing!`);
} catch (e) {
return await interaction.followUp(`Somthing went wrong: ${e}`);
}
}
Dependencies: "devDependencies": { "@discord-player/extractor": "^4.4.5", "@discordjs/builders": "^1.7.0", "@discordjs/opus": "^0.9.0", "@discordjs/rest": "^2.2.0", "@discordjs/voice": "^0.16.0", "discord-api-types": "^0.37.67", "discord-player": "^6.6.6", "discord.js": "^14.14.1", "dotenv": "^16.3.1", "lodash": "^4.17.21", "youtube-ext": "^1.1.16" }
6 replies
DIAdiscord.js - Imagine an app
Created by miawue on 11/24/2022 in #djs-questions
Options is not working for me
6 replies