Discordjs Interaction Failed (can't click second time)

29 Views Asked by At

I am developing a special bot for Discord, but when I click on the button for the second time in the temp voice section, I get "interaction failed and I do not receive an error in the console.

Voice lock unlock example:

if(customId == 'tempVoiceLockUnlock'){

      // Defer the initial reply to show that the bot is processing
      await interaction.deferUpdate();

      // Simulate some processing time (you can replace this with actual processing)
      // await new Promise((resolve) => setTimeout(resolve, 500));

      // Check if everyone has the "VIEW_CHANNEL" permission
      const hasConnect = channel.permissionsFor(everyoneRole).has('Connect');

      // Toggle the permission
      if(hasConnect){
        channel.permissionOverwrites.edit(everyoneRole, { Connect: false, });
      }else{
        channel.permissionOverwrites.edit(everyoneRole, { Connect: true, });
      }
      interaction.followUp({ content: `Voice channel ${hasConnect ? 'locked' : 'unlocked'}.`, ephemeral: true });
      
}

Reply or edit etc. I tried but it still didn't work.

code

0

There are 0 best solutions below