'How to hide slash command to specific user or channel Discord.js v13

Is it possible to hide slash command in discord.js v13.1.0 ? I tried to add some permission but nothing that i found worked like the

" command.permissions.add({ "permission array" }) "

If there is a way to do it it would be amazing

I saw that the support saw that issue but do you have any idea about when they would add this feature ?



Solution 1:[1]

According to discordjs guide, you need to use ApplicationCommandPermissionsManager#set() or ApplicationCommandPermissionsManager#add():

using set()

const fullPermissions = [
    {
        id: '123456789012345678',
        permissions: [{
            id: '224617799434108928',
            type: 'USER',
            permission: false,
        }],
    },
    {
        id: '876543210987654321',
        permissions: [{
            id: '464464090157416448',
            type: 'ROLE',
            permission: true,
        }],
    },
];

await client.guilds.cache.get('123456789012345678')?.commands.permissions.set({ fullPermissions });

using add()

if (!client.application?.owner) await client.application?.fetch();

const command = await client.guilds.cache.get('123456789012345678')?.commands.fetch('876543210987654321');

const permissions = [
    {
        id: '224617799434108928',
        type: 'USER',
        permission: false,
    },
];

await command.permissions.add({ permissions });

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andromeda