Default Permissions

Hello! As i do slash commands only, is it possible to set the Default Permission, so that the guild admins can override perms if they want?
Solution:
```ts import { Command, type ChatInputCommand } from '@sapphire/framework'; import { applyLocalizedBuilder } from '@sapphire/plugin-i18next'; import { PermissionFlagsBits } from 'discord-api-types/v10'; ...
Jump to solution
4 Replies
Fabi
Fabi8mo ago
I dont want to hardcode perms like that
No description
Favna
Favna8mo ago
requiredXPermissions are sapphire preconditions, not slash permissions. Set default permissions for slash commands in the registry function where you assign the other properties for the command. Other than that, no those precondition properties cannot be set to a default for all commands.
Fabi
Fabi8mo ago
How would i do this in the registry? currently i have it like that
export class UserCommand extends Command {
public override registerApplicationCommands(registry: ChatInputCommand.Registry) {
registry.registerChatInputCommand((builder) => applyLocalizedBuilder(builder, 'setup:CommandName', 'setup:CommandDescription'));
}

public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
await interaction.reply({
content: `...`,
ephemeral: true
});
}
}
export class UserCommand extends Command {
public override registerApplicationCommands(registry: ChatInputCommand.Registry) {
registry.registerChatInputCommand((builder) => applyLocalizedBuilder(builder, 'setup:CommandName', 'setup:CommandDescription'));
}

public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
await interaction.reply({
content: `...`,
ephemeral: true
});
}
}
Solution
Favna
Favna8mo ago
import { Command, type ChatInputCommand } from '@sapphire/framework';
import { applyLocalizedBuilder } from '@sapphire/plugin-i18next';
import { PermissionFlagsBits } from 'discord-api-types/v10';

export class UserCommand extends Command {
public override registerApplicationCommands(registry: ChatInputCommand.Registry) {
registry.registerChatInputCommand((builder) =>
applyLocalizedBuilder(builder, 'setup:CommandName', 'setup:CommandDescription').setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
);
}

public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
await interaction.reply({
content: `...`,
ephemeral: true
});
}
}
import { Command, type ChatInputCommand } from '@sapphire/framework';
import { applyLocalizedBuilder } from '@sapphire/plugin-i18next';
import { PermissionFlagsBits } from 'discord-api-types/v10';

export class UserCommand extends Command {
public override registerApplicationCommands(registry: ChatInputCommand.Registry) {
registry.registerChatInputCommand((builder) =>
applyLocalizedBuilder(builder, 'setup:CommandName', 'setup:CommandDescription').setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
);
}

public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
await interaction.reply({
content: `...`,
ephemeral: true
});
}
}
Want results from more Discord servers?
Add your server