Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

209
Views
Trying to save in quick.db channel after interaction but cannot save channel and prevent making channnel

I am using 'discord.js' v13 library with 'quick.db' npm package.

I am trying to save the channel from the interaction, but when I do it for first time bot sends me that I have already the channel. When I try for a second and third time, it sends me the same message and recreates a channel.

The JavaScript code I am using:

client.on('interactionCreate', async(interaction) => {
  if (interaction.customId === "general") {
    await interaction.deferUpdate();

    const channel = await interaction.guild.channels.create(`name-${interaction.member.user.username}`, {
      type: 'GUILD_TEXT'
    }).then(async channel => {
        const del = new MessageButton()
          .setStyle("DANGER")
          .setLabel("๐Ÿ”’ Delete")
          .setCustomId("del");
        const delbut = new MessageActionRow()
          .addComponents([
            [del]
          ])
        await channel.send({
          content: `test`,
          embeds: [test],
          components: [delbut]
        }).catch(e => {
          console.log(e.message)
        });
        const channelID = await interaction.guild.channels.cache.get(channel.id);
        const newchannel = await db.set(`channel_${interaction.guild.id}_${interaction.channel.id}`, interaction.member.id)

        if (newchannel) {
          const savedChannel = await db.get(`channel_${interaction.guild.id}_${interaction.channel.id}`)

          interaction.member.send({
            content: `Channel: ${channelID}`
          })
        }
      }
    })

  if (interaction.customId === "del") {
    await interaction.deferUpdate();
    interaction.message.channel.delete()
  }

}
});
about 4 years ago ยท Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!