Skip to content
Functioncorev0.14.0

RequireRole

Requires the caller to hold roleId, read from the member's role ids. Refuses outside a guild first, then when the role is missing. Roles are guild-global, so they don't vary by scope.

See also:the @Gated decorator from your transport package

RequireRole(
    roleId: string,
    options?: RequireRoleOptions
): Gate<GateContextBase, "RequireRole">
\@Gated(RequireRole('123456789012345678'))
\@SlashRoute('vip')
class VipHandler extends SlashHandler<'vip'> {
    async execute() {
        // ...
    }
}

roleId

roleId: string

The role snowflake the caller must hold.

options?

Replace a refusal with a Notice class as notInGuild or missingRole.