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

0

I'm following a tutorial on discord.js, making a ticket bot. I have double-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 SO, 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("
discord discord.js javascript node.js
2021-11-23 20:58:37
1

0

It seems you're using discord.js v13 and trying some old code. In v13 the channel#updateOverwrite() method is removed and while in previous version channel#permissionOverwrites was a collection of overwrites, in v13 it's a PermissionOverwriteManager. It means, you should use its .edit() method to update overwrites:

channel.permissionOverwrites.edit(
  message.author, 
  { SEND_MESSAGES: false, VIEW_CHANNEL: false },
)
2021-11-23 21:49:11

In other languages

This page is in other languages

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................