From 889b86b0191b36831d726c02d8dd02750d18e197 Mon Sep 17 00:00:00 2001 From: neru Date: Tue, 13 Jan 2026 18:37:11 -0300 Subject: [PATCH] feat: add key methods --- src/commands.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/commands.ts b/src/commands.ts index 5ec6705..98133df 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -99,6 +99,22 @@ export class CommandManager { return this.getAll().filter((cmd) => !!cmd.name); } + public getGuildKeys(): Record { + return this.mergeKeys('guild_keys'); + } + + public getUserKeys(): Record { + return this.mergeKeys('user_keys'); + } + + private mergeKeys( + keyType: 'guild_keys' | 'user_keys' + ): Record { + return this.getAll() + .flatMap((cmd) => (cmd[keyType] ? [cmd[keyType]] : [])) + .reduce((acc, val) => Object.assign(acc, val), {}); + } + /* internal */