const { SlashCommandBuilder, EmbedBuilder, MessageFlags, } = require("discord.js"); module.exports = { data: new SlashCommandBuilder() .setName("play") .setDescription("Play a song from YouTube, Spotify, or other platforms") .addStringOption((option) => option .setName("query") .setDescription("The song name, URL, or search query") .setRequired(true) ), async execute(interaction) { if (!interaction.member.voice.channel) { return await interaction.reply({ content: "❌ You need to be in a voice channel to play music!", flags: MessageFlags.Ephemeral, }); } const permissions = interaction.member.voice.channel.permissionsFor( interaction.client.user ); if (!permissions.has(["Connect", "Speak"])) { return await interaction.reply({ content: "❌ I need permissions to join and speak in your voice channel!", flags: MessageFlags.Ephemeral, }); } const query = interaction.options.getString("query"); const aqua = interaction.client.aqua; try { const results = await aqua.resolve({ query: query, source: "ytsearch", requester: interaction.user, }); if (!results || !results.tracks || results.tracks.length === 0) { return await interaction.reply({ content: "❌ No results found for your search query!", }); } const player = aqua.createConnection({ guildId: interaction.guild.id, textChannel: interaction.channel.id, voiceChannel: interaction.member.voice.channel.id, defaultVolume: 80, deaf: true, }); const track = results.tracks[0]; if (player.queue && player.queue.add) { player.queue.add(track); } if (!player.playing && !player.paused) { await player.play(); } const embed = new EmbedBuilder() .setColor(0x00ff00) .setTitle("🎵 Added to Queue") .setDescription(`**[${track.info.title}](${track.info.uri})**`) .addFields( { name: "Author", value: track.info.author || "Unknown", inline: true, }, { name: "Duration", value: track.info.isStream ? "Live Stream" : `${Math.floor(track.info.length / 60000)}:${Math.floor( (track.info.length % 60000) / 1000 ) .toString() .padStart(2, "0")}`, inline: true, }, { name: "Position in Queue", value: `${player.queue.size}`, inline: true, } ) .setThumbnail(track.info.artworkUrl) .setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: interaction.user.displayAvatarURL(), }); await interaction.reply({ embeds: [embed] }); } catch (error) { console.error("Error in play command:", error); await interaction.reply({ content: "❌ An error occurred while trying to play the track!", }); } }, }; ▶️ Now playing: All I Need in guild 1403488603027279872 Error in play command: DiscordAPIError[40060]: Interaction has already been acknowledged. at handleErrors (/workspaces/Revert/node_modules/@discordjs/rest/dist/index.js:748:13) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async BurstHandler.runRequest (/workspaces/Revert/node_modules/@discordjs/rest/dist/index.js:852:23) at async _REST.request (/workspaces/Revert/node_modules/@discordjs/rest/dist/index.js:1293:22) at async ChatInputCommandInteraction.reply (/workspaces/Revert/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:200:22) at async Object.execute (/workspaces/Revert/src/commands/play.js:105:9) at async Object.execute (/workspaces/Revert/src/events/interactionCreate.js:10:7) { requestBody: { files: [], json: { type: 4, data: [Object] } }, rawError: { message: 'Interaction has already been acknowledged.', code: 40060 }, code: 40060, status: 400, method: 'POST', url: 'https://discord.com/api/v10/interactions/1406434262864891904/aW50ZXJhY3Rpb246MTQwNjQzNDI2Mjg2NDg5MTkwNDpjM0J5SnduTFJWR1JienRtQW9CekJpaU5EcERBeU9wNUlBaEUwSmphT1Z4SjA1MUJCb2JBUXFrMWFKWWVIbWVTMjBTd1o0NEFINjVvTlRGclBwVjAzenA1cUY1c1VTM3U1R2hUSGFZY2ExdXVMb0ZYdkF4b3J3eWtRY0s4TDUyZA/callback?with_response=false' } Error executing command: DiscordAPIError[40060]: Interaction has already been acknowledged. at handleErrors (/workspaces/Revert/node_modules/@discordjs/rest/dist/index.js:748:13) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async BurstHandler.runRequest (/workspaces/Revert/node_modules/@discordjs/rest/dist/index.js:852:23) at async _REST.request (/workspaces/Revert/node_modules/@discordjs/rest/dist/index.js:1293:22) at async ChatInputCommandInteraction.reply (/workspaces/Revert/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:200:22) at async Object.execute (/workspaces/Revert/src/commands/play.js:111:9) at async Object.execute (/workspaces/Revert/src/events/interactionCreate.js:10:7) { requestBody: { files: [], json: { type: 4, data: [Object] } }, rawError: { message: 'Interaction has already been acknowledged.', code: 40060 }, code: 40060, status: 400, method: 'POST', url: 'https://discord.com/api/v10/interactions/1406434262864891904/aW50ZXJhY3Rpb246MTQwNjQzNDI2Mjg2NDg5MTkwNDpjM0J5SnduTFJWR1JienRtQW9CekJpaU5EcERBeU9wNUlBaEUwSmphT1Z4SjA1MUJCb2JBUXFrMWFKWWVIbWVTMjBTd1o0NEFINjVvTlRGclBwVjAzenA1cUY1c1VTM3U1R2hUSGFZY2ExdXVMb0ZYdkF4b3J3eWtRY0s4TDUyZA/callback?with_response=false' }