I'm making a discord slash command nowplaying
with save button in it and sent the current music playing in user's dm. i manage to create the buttons working but my problem is after clicking the button "Save Song" it says "This interaction failed" tho the buttons works it sent a embed of the current music playing. Can someone help me why it saying that error?
Node: v17.7.2
Discord: ^13.2.0
my InteractionCreate
events for the button "Save Song"
const client = require("../index");
const { MessageEmbed } = require('discord.js');
const ee = require('../config.json');
client.on("interactionCreate", async (interaction) => {
// Slash Command Handling
if (interaction.isCommand()) {
await interaction.deferReply({ ephemeral: false }).catch(() => {});
const cmd = client.slashCommands.get(interaction.commandName);
if (!cmd)
return interaction.followUp({ content: "An error has occured " });
const args = [];
for (let option of interaction.options.data) {
if (option.type === "SUB_COMMAND") {
if (option.name) args.push(option.name);
option.options?.forEach((x) => {
if (x.value) args.push(x.value);
});
} else if (option.value) args.push(option.value);
}
interaction.member = interaction.guild.members.cache.get(interaction.user.id);
cmd.run(client, interaction, args);
}
// Context Menu Handling
if (interaction.isContextMenu()) {
await interaction.deferReply({ ephemeral: false });
const command = client.slashCommands.get(interaction.commandName);
if (command) command.run(client, interaction);
}
//Save Song button function
if (interaction.isButton()){
const queue = client.distube.getQueue(interaction.guildId);
switch (interaction.customId) {
case 'saveTrack': {
if (!queue || !queue.playing){
return interaction.followUp({ content: `No music currently playing. ❌`, ephemeral: true, components: [] });
} else {
const song = queue.songs[0];
const but_save = new MessageEmbed()
.setColor(ee.color)
.setTitle(client.user.username " - Save Track")
.setThumbnail(client.user.displayAvatarURL())
.addField(`