Crashing on connection.destroy();

async function handleLeaveCommand(interaction) {
const connection = getVoiceConnection(interaction.guild.id);
if (!connection) {
const cannotJoinEmbed = new EmbedBuilder()
.setColor("FF4C4C")
.setDescription("I'm not in a voice channel! 😅");

await interaction.reply({ embeds: [cannotJoinEmbed] });
} else {
connection.destroy();
const leftEmbed = new EmbedBuilder()
.setColor("81C784")
.setDescription("Successfully left the voice chat.");

await interaction.reply({ embeds: [leftEmbed] });
}
}
async function handleLeaveCommand(interaction) {
const connection = getVoiceConnection(interaction.guild.id);
if (!connection) {
const cannotJoinEmbed = new EmbedBuilder()
.setColor("FF4C4C")
.setDescription("I'm not in a voice channel! 😅");

await interaction.reply({ embeds: [cannotJoinEmbed] });
} else {
connection.destroy();
const leftEmbed = new EmbedBuilder()
.setColor("81C784")
.setDescription("Successfully left the voice chat.");

await interaction.reply({ embeds: [leftEmbed] });
}
}
At connection.destroy(); the following error is presented:
node:internal/fs/rimraf:60
callback(err);
^

TypeError: callback is not a function
at CB (node:internal/fs/rimraf:60:5)
at FSReqCallback.oncomplete (node:fs:194:23)

Node.js v20.12.2
node:internal/fs/rimraf:60
callback(err);
^

TypeError: callback is not a function
at CB (node:internal/fs/rimraf:60:5)
at FSReqCallback.oncomplete (node:fs:194:23)

Node.js v20.12.2
I am not sure what or why this issue is occuring, and any help would be greatly appreciated. Thanks!
1 Reply
d.js toolkit
d.js toolkit•4mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Want results from more Discord servers?
Add your server