Skip to content
This repository was archived by the owner on Dec 24, 2021. It is now read-only.

Commit 6b9e4ee

Browse files
authored
Allow override of Command.throttle (#372)
- Make `Command.throttle` protected instead of private, allowing children to safely override this handling when using typescript. - Fix the return type of `Command.throttle` to acknowledge the null response where a command is not throttling. Given throttling is a per-command behaviour, it would be handy to be able to provide custom throttling checks as needed. I.e. throttling for all (incl. owners), global throttling instead of per-user, etc
1 parent ac05805 commit 6b9e4ee

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/commands/base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ class Command {
361361
* Creates/obtains the throttle object for a user, if necessary (owners are excluded)
362362
* @param {string} userID - ID of the user to throttle for
363363
* @return {?Object}
364-
* @private
364+
* @protected
365365
*/
366366
throttle(userID) {
367367
if(!this.throttling || this.client.isOwner(userID)) return null;

typings/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ declare module 'discord.js-commando' {
6363
private _globalEnabled: boolean;
6464
private _throttles: Map<string, object>;
6565

66-
private throttle(userID: string): object;
66+
protected throttle(userID: string): object | null;
6767

6868
private static validateInfo(client: CommandoClient, info: CommandInfo);
6969

0 commit comments

Comments
 (0)