diff --git a/changelog.d/445.bugfix b/changelog.d/445.bugfix new file mode 100644 index 00000000..a5a7c9ed --- /dev/null +++ b/changelog.d/445.bugfix @@ -0,0 +1 @@ +Fixed issue where `!hookshot gitlab project` commands would fail with a "Failed to handle command." error. \ No newline at end of file diff --git a/src/BotCommands.ts b/src/BotCommands.ts index 4006f2bb..e92b5bc9 100644 --- a/src/BotCommands.ts +++ b/src/BotCommands.ts @@ -88,10 +88,31 @@ export function compileBotCommands(...prototypes: Record { +: Promise { if (prefix) { if (!command.startsWith(prefix)) { return {handled: false}; @@ -106,10 +127,10 @@ export async function handleCommand( if (command) { const permissionService = command.permissionService || defaultPermissionService; if (permissionService && !permissionCheckFn(permissionService, command.permissionLevel || BridgePermissionLevel.commands)) { - return {handled: true, error: "You do not have permission to use this command."}; + return {handled: true, humanError: "You do not have permission to use this command."}; } if (command.requiredArgs && command.requiredArgs.length > parts.length - i) { - return {handled: true, error: "Missing at least one required parameter."}; + return {handled: true, humanError: "Missing at least one required parameter."}; } const args = parts.slice(i); if (command.includeUserId) { @@ -121,9 +142,9 @@ export async function handleCommand( } catch (ex) { const commandError = ex as CommandError; if (ex instanceof ApiError) { - return {handled: true, error: ex.error, humanError: ex.error}; + return {handled: true, humanError: ex.error}; } - return {handled: true, error: commandError.message, humanError: commandError.humanError}; + return {handled: true, error: commandError, humanError: commandError.humanError}; } } } diff --git a/src/Bridge.ts b/src/Bridge.ts index e97327d7..387c26a4 100644 --- a/src/Bridge.ts +++ b/src/Bridge.ts @@ -845,7 +845,7 @@ export class Bridge { messageClient: this.messageClient, storage: this.storage, github: this.github, - getAllConnectionsOfType: this.connectionManager.getAllConnectionsOfType.bind(this), + getAllConnectionsOfType: this.connectionManager.getAllConnectionsOfType.bind(this.connectionManager), }, this.getOrCreateAdminRoom.bind(this), ) diff --git a/src/Connections/CommandConnection.ts b/src/Connections/CommandConnection.ts index 4ec19acb..cc6c8d69 100644 --- a/src/Connections/CommandConnection.ts +++ b/src/Connections/CommandConnection.ts @@ -46,8 +46,8 @@ export abstract class CommandConnection