79309929

Date: 2024-12-26 16:30:31
Score: 0.5
Natty:
Report link

Turns out there is a way to do this using the Discord app itself.

  1. Set your command to be invisible to all members except admins by adding .setDefaultMemberPermissions(0) to its data property, e.g.
{
  data: new SlashCommandBuilder()
    .setName("protect")
    .setDescription("Protect a user from all visits")
    .setDefaultMemberPermissions(0)
    ),
  async execute(interaction: ChatInputCommandInteraction) {
    // action execution code...
  },
}
  1. Go into your Server Settings and select the 'Integrations' panel.
  2. Select your bot, and you will see a 'Commands' section.
  3. Click on the command you want to customise. You will now see a panel where you can configure overrides.
  4. Select 'Add roles or members', then select the member you want to give access to. You can now see the user listed under 'Role & member overrides'.

I do not believe there is a way to do this in a programmatic manner using Discord.js, but this option fits my use case.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Liam