• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

358
Views
Discord.js error "TypeError: channel.updateOverwrite is not a function"

When I'm trying to change the channel permissions to lock users from sending messages, this error pops up no matter what I do.

TypeError: channel.updateOverwrite is not a function

Is there anything wrong?

module.exports =
{
    async execute(message, args)
    {
            const role = message.guild.roles.cache.find(r => r.name === '@everyone')

            let channel = message.mentions.channels.first() || args[0]
            if(!channel) channel = message.channel

            if(channel.permissionsFor(message.guild.id).has('SEND_MESSAGES') === false) return message.channel.send(`${channel} is already locked.`)

            await channel.updateOverwrite(message.guild.id, { SEND_MESSAGES: false }).catch(() => {}) // Line in which the error happens
            await channel.updateOverwrite(role, { SEND_MESSAGES: false} ).catch(() => {})
    }
}
about 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It seems you're using discord.js v13 but using 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:

await channel
  .permissionOverwrites.edit(message.guild.id, { SEND_MESSAGES: false })
await channel
  .permissionOverwrites.edit(role, { SEND_MESSAGES: false })
about 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error