diff --git a/src/Core/Interactions/IInteractionBase.cs b/src/Core/Interactions/IInteractionBase.cs index 0ebedb5..4dd8eb7 100644 --- a/src/Core/Interactions/IInteractionBase.cs +++ b/src/Core/Interactions/IInteractionBase.cs @@ -1,13 +1,14 @@ using System; +using Geekbot.Core.Interactions.Request; using Geekbot.Core.Interactions.Response; namespace Geekbot.Core.Interactions { public interface IInteractionBase { - void BeforeExecute(); - void AfterExecute(); - void OnException(Exception e); - InteractionResponse GetExceptionResponse(); + void BeforeExecute(Interaction interaction); + void AfterExecute(Interaction interaction); + void OnException(Interaction interaction, Exception e); + InteractionResponse GetExceptionResponse(Interaction interaction); } } \ No newline at end of file diff --git a/src/Core/Interactions/InteractionBase.cs b/src/Core/Interactions/InteractionBase.cs index cd9de68..26c0a3c 100644 --- a/src/Core/Interactions/InteractionBase.cs +++ b/src/Core/Interactions/InteractionBase.cs @@ -9,23 +9,23 @@ namespace Geekbot.Core.Interactions { public abstract class InteractionBase : IInteractionBase { - public virtual void BeforeExecute() + public virtual void BeforeExecute(Interaction interaction) { } - public virtual void AfterExecute() + public virtual void AfterExecute(Interaction interaction) { } - public virtual void OnException(Exception exception) + public virtual void OnException(Interaction interaction, Exception exception) { if (!SentrySdk.IsEnabled) return; SentrySdk.CaptureException(exception); } - public virtual InteractionResponse GetExceptionResponse() + public virtual InteractionResponse GetExceptionResponse(Interaction interaction) { return new InteractionResponse() { @@ -40,9 +40,13 @@ namespace Geekbot.Core.Interactions public abstract Command GetCommandInfo(); public abstract Task Exec(Interaction interaction); - void IInteractionBase.BeforeExecute() => this.BeforeExecute(); - void IInteractionBase.AfterExecute() => this.AfterExecute(); - void IInteractionBase.OnException(Exception e) => this.OnException(e); - InteractionResponse IInteractionBase.GetExceptionResponse() => this.GetExceptionResponse(); + void IInteractionBase.BeforeExecute(Interaction interaction) + => this.BeforeExecute(interaction); + void IInteractionBase.AfterExecute(Interaction interaction) + => this.AfterExecute(interaction); + void IInteractionBase.OnException(Interaction interaction, Exception e) + => this.OnException(interaction, e); + InteractionResponse IInteractionBase.GetExceptionResponse(Interaction interaction) + => this.GetExceptionResponse(interaction); } } \ No newline at end of file diff --git a/src/Core/Interactions/InteractionCommandManager.cs b/src/Core/Interactions/InteractionCommandManager.cs index 281c02d..fd21c5f 100644 --- a/src/Core/Interactions/InteractionCommandManager.cs +++ b/src/Core/Interactions/InteractionCommandManager.cs @@ -67,17 +67,17 @@ namespace Geekbot.Core.Interactions InteractionResponse response; try { - command.BeforeExecute(); + command.BeforeExecute(interaction); response = await command.Exec(interaction); } catch (Exception e) { - command.OnException(e); - response = command.GetExceptionResponse(); + command.OnException(interaction, e); + response = command.GetExceptionResponse(interaction); } finally { - command.AfterExecute(); + command.AfterExecute(interaction); } return response;