-1

I'm trying to make a ticket system with discord.js v13, but the ephemeral method doesn't work and, when my bot turn on, i need to click one time in the button to activate the system. print

My code:

const { MessageActionRow, MessageButton, MessageEmbed, Permissions } = require('discord.js');
const db = require("quick.db");

exports.run = async (client, interaction) => {
    
    if (!interaction.isButton()) return;

    interaction.deferUpdate();

    let getContador = await db.get('counter')

    if(getContador === null) {

    let contador = await db.set("counter", 1)

    }
    await db.add("counter", 1)

    let tcID = "895323735702253569"
    let tmID = "895358127950659604"

    const filter = i => i.customId === 'OPENTICKET'
    const collector = interaction.channel.createMessageComponentCollector({ filter, max: 1 });

    collector.on("collect", async i => {

            let cTicket = await i.guild.channels.create(`┆Ticket ${getContador}`, {
                type: 'GUILD_TEXT',
                permissionOverwrites: [

                    {
                        id: i.guild.id,
                        deny: [Permissions.FLAGS.VIEW_CHANNEL],
                    },
                    {
                        id: i.user.id,
                        allow: [Permissions.FLAGS.VIEW_CHANNEL, Permissions.FLAGS.SEND_MESSAGES],
                    },

                ]
            })
            
            await interaction.channel.messages.cache.get(tmID).reply({ content: `... ${cTicket.toString()}...`, ephemeral: true })

    })
}
snowe
  • 3
  • 1
  • 5

1 Answers1

2

You are replying to a normal message. If you would like an ephemeral message, you have to directly reply to the interaction.

interaction.reply({ 
  content: `... ${cTicket.toString()}...`,
  ephemeral: true 
})
MrMythical
  • 8,908
  • 2
  • 17
  • 45