TypeError: interaction.update is not a function [discord.js v14]

548 Views Asked by At

Code:

} else if (interaction.customId == "close-ticket") {
                const guild = client.guilds.cache.get(interaction.guildId);
                const chan = guild.channels.cache.get(interaction.channelId);

                const row = new ActionRowBuilder()
                    .addComponents(
                        new ButtonBuilder()
                            .setCustomId('confirm-close')
                            .setLabel('Κλείσε το ticket!')
                            .setStyle(ButtonStyle.Danger),
                        new ButtonBuilder()
                            .setCustomId('no')
                            .setLabel('Ακύρωση!')
                            .setStyle(ButtonStyle.Secondary),
                    );

                const verif = await interaction.reply({
                    content: 'Είστε βέβαιοι ότι θέλετε να κλείσετε το ticket σας;',
                    components: [row]
                });

                const collector = interaction.channel.createMessageComponentCollector({
                    componentType: 'BUTTON',
                    time: 10000
                });

                collector.on('collect', i => {
                    if (i.customId == 'confirm-close') {
                        interaction.editReply({
                            content: `Το ticket έκλεισε απο τον/την: <@!${interaction.user.id}>`,
                            components: []
                        });

                        chan.edit({
                            name: `closed-${chan.name}`,
                            permissionOverwrites: [
                                {
                                    id: client.users.cache.get(chan.topic),
                                    deny: [PermissionsBitField.Flags.ViewChannel],
                                },
                                {
                                    id: config.rolesupport,
                                    allow: [PermissionsBitField.Flags.ViewChannel],
                                },
                                {
                                    id: interaction.guild.roles.everyone,
                                    deny: [PermissionsBitField.Flags.ViewChannel],
                                },
                            ],
                        })
                            .then(async () => {
                                const embed = new client.discord.MessageEmbed()
                                    .setColor('#429cf5')
                                    .setAuthor('Ticket', `${client.config.serverlogo}`)
                                    .setDescription('Πατήστε το `️Διαγραφή του ticket!`, για να διαγράψετε το ticket!')
                                    .setFooter(`${client.config.servername}`, `${client.config.serverlogo}`)
                                    .setTimestamp();

                                const row = new client.discord.MessageActionRow()
                                    .addComponents(
                                        new client.discord.MessageButton()
                                            .setCustomId('delete-ticket')
                                            .setLabel('Διαγραφή του ticket!')
                                            .setEmoji('️')
                                            .setStyle('DANGER'),
                                    );

                                chan.send({
                                    embeds: [embed],
                                    components: [row]
                                });
                            });

                        collector.stop();
                    };
                    if (interaction.customId == 'no') {
                        interaction.reply({
                            content: 'Η κατάργηση του ticket σας ακυρώθηκε !',
                            components: []
                        });
                        collector.stop();
                    };
                });

                collector.on('end', (interaction) => {
                    if (interaction.size < 1) {
                        interaction.reply({
                            content: 'Η κατάργηση του ticket σας ακυρώθηκε !',
                            components: []
                        });
                    };
                });

Error:

interaction.reply({
            ^

TypeError: interaction.reply is not a function

So.. what is the new function to update an interaction reply ? Can somebody send a fix version of this code or suggest me a fix ? Thanks in advance :)

(Idk what extra detail i should add)(Idk what extra detail i should add)(Idk what extra detail i should add)(Idk what extra detail i should add)(Idk what extra detail i should add)(Idk what extra detail i should add)(Idk what extra detail i should add)(Idk what extra detail i should add)(Idk what extra detail i should add)

1

There are 1 best solutions below

2
Geoduck On

There are some issues. What you are likely running into is you are redefining interaction and hiding the original:

                collector.on('end', (interaction) => {
                    if (interaction.size < 1) {
                        interaction.reply({
                            content: 'Η κατάργηση του ticket σας ακυρώθηκε !',
                            components: []
                        });
                    };
                });

In the above code, interaction is no longer the discord interaction, but some other object or value. My guess is you wanted something like:

                collector.on('end', (i) => {
                    if (i.size < 1) {
                        interaction.reply({
                            content: 'Η κατάργηση του ticket σας ακυρώθηκε !',
                            components: []
                        });
                    };
                });

You have a similar issue above, where you check if (interaction.customId == 'no') {

That will never be "no" (barring some unexpected api that modifies it external to your code), because you are in an if statement that already determined it is "close-ticket". You probably wanted:

if (i.customId == 'no') {