How to lock and unlock an channel using discord.js v13.4
11:50 11 Jan 2022

So I tried a lot of ways to locking a channel to a specific role, this is one of my attempt code:

Locking the channel

const Command = require("../structures/Command.js");
const { Permissions } = require('discord.js');

module.exports = new Command({
    name: "lock",
    description: "lock the channel that the command is executed",

    async run(message, args, client) {
        if (message.author.bot) return;
        if (message.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)){
            let role = message.guild.roles.cache(r => r.id === "895151537511362600");
            role.overwritePermissions(UserResolvable, {
    VIEW_CHANNEL: true,
    SEND_MESSAGES: false,
    READ_MESSAGE_HISTORY: true,
    ATTACH_FILES: false
});            
        } else message.reply(`why do you want to use a mod command when you're not a mod`)

    }
});

Unlocking:

const Command = require("../structures/Command.js");
const { Permissions } = require('discord.js');

module.exports = new Command({
    name: "unlock",
    description: "unlock the channel that the command is executed",

    async run(message, args, client) {
        if (message.author.bot) return;
        if (message.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)){
            let role = message.guild.roles.cache(r => r.id === "895151537511362600");
            role.overwritePermissions(UserResolvable, {
    VIEW_CHANNEL: true,
    SEND_MESSAGES: true,
    READ_MESSAGE_HISTORY: true,
    ATTACH_FILES: true
});            
        } else message.reply(`why do you want to use a mod command when you're not a mod`)

    }
});

It didn't work, also returned a error say UserResolvable is not defined I also tried this method and it still didn't work

javascript discord.js