Why am I getting: TypeError: channel.updateOverwrite is not a function


I’m following a tutorial on discord.js, making a ticket bot. I have doubled checked and I am still getting the same error:

TypeError: channel.updateOverwrite is not a function

I’ve looked over all the StackOverflow questions that I could find, but none has worked for me. I have also explored a little deeper outside of stack, still no help. Here is my code:

module.exports = {
    name: 'ticket',
    description: 'Open a ticket!',
    async execute(client, message, args, cmd, Discord) {
        // creates tickets
        let channel = await message.guild.channels.create(
            `ticket: ${message.author.tag}`,
            { type: 'text' }
        );
        await channel.setParent('912495738947260446');

        // updates channel perms

        channel.updateOverwrite(message.guild.id, {
            SEND_MESSAGE: false,
            VIEW_CHANNEL: false
        });

        channel.updateOverwrite(message.author, {
            SEND_MESSAGE: true,
            VIEW_CHANNEL: true
        });

        const reactionMessage = await channel.send('Thanks for opening a ticket! A staff member will be with you shortly. While you are here, please tell us why you opened this ticket.');

        try {
            await reactionMessage.react("🔒");
            await reactionMessage.react("🗑️");
        } catch(err) {
            channel.send('Error sending emojis! Please tell a developer to check the console!');
            throw err;
        }

        const collector = reactionMessage.createReactionCollector((reaction, user) => message.guild.members.cache.find((member) => member.id === user.id).hasPermission('ADMINISTRATOR'), {dispose: true});

        collector.on('collect', (reaction, user) => {
            switch (reaction.emoji.name) {
                case "🔒":
                    channel.updateOverwrite(message.author, { SEND_MESSAGE: false, VIEW_CHANNEL: false});
                    channel.setname(`🔒 ${channel.name}`)
                    break;
                case "🗑️":
                    channel.send('Deleting Channel in 10 seconds!');
                    setTimeout(() => channel.delete(), 10000);
                    break;
            }
        });


    }
}

Source: JavaSript – Stack Overflow

November 23, 2021
Category : News
Tags: discord | discord.js | javascript | node.js

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.