Applies a single custom resolver to a command through a decorator
CreateResolver('key', (arg, _possible, message, [action]) => {
if (action === 'show' || arg) return arg || '';
throw message.language.get('commandConfNoKey');
})
Name of the custom argument resolver
Function describing how to resolve the argument
Applies a set of custom resolvers to a command through a decorator
CreateResolvers([
[
'key',
(arg, _possible, message, [action]) => {
if (action === 'show' || arg) return arg || '';
throw message.language.get('commandConfNoKey');
}
]
])
Array of custom resolvers to apply to a command
Utility to make a class decorator with lighter syntax and inferred types.
The class to decorate
Utility to make function inhibitors.
// No fallback (returns undefined)
function requiresPermission(value: number) {
return createFunctionInhibitor((message: KlasaMessage) =>
message.hasAtLeastPermissionLevel(value));
}
// With fallback
function requiresPermission(
value: number,
fallback: () => unknown = () => undefined
) {
return createFunctionInhibitor((message: KlasaMessage) =>
message.hasAtLeastPermissionLevel(value), fallback);
}
The function that defines whether or not the function should be run, returning the returned value from fallback
The fallback value that defines what the method should return in case the inhibitor fails
Utility to make a method decorator with lighter syntax and inferred types.
// Enumerable function
function enumerable(value: boolean) {
return createMethodDecorator((_target, _propertyKey, descriptor) => {
descriptor.enumerable = value;
});
}
The method to decorate
Allows you to set permissions required for individual methods
Permissions that the method should have
Requires the message to be run in a dm context, this decorator requires the first argument to be a KlasaMessage
instance
The fallback value passed to createFunctionInhibitor
Requires the message to be run in a guild context, this decorator requires the first argument to be a KlasaMessage
instance
The fallback value passed to createFunctionInhibitor
Requires a permission, this decorator requires the first argument to be a KlasaMessage
instance
The minimum permission level for this inhibitor to pass
The fallback value passed to createFunctionInhibitor
Generated using TypeDoc
Decorator function that applies given options to any Klasa piece
1.0.0