feat: add key methods
This commit is contained in:
@@ -99,6 +99,22 @@ export class CommandManager {
|
||||
return this.getAll().filter((cmd) => !!cmd.name);
|
||||
}
|
||||
|
||||
public getGuildKeys(): Record<string, unknown> {
|
||||
return this.mergeKeys('guild_keys');
|
||||
}
|
||||
|
||||
public getUserKeys(): Record<string, unknown> {
|
||||
return this.mergeKeys('user_keys');
|
||||
}
|
||||
|
||||
private mergeKeys(
|
||||
keyType: 'guild_keys' | 'user_keys'
|
||||
): Record<string, unknown> {
|
||||
return this.getAll()
|
||||
.flatMap((cmd) => (cmd[keyType] ? [cmd[keyType]] : []))
|
||||
.reduce((acc, val) => Object.assign(acc, val), {});
|
||||
}
|
||||
|
||||
/*
|
||||
internal
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user