Browse Source

Merge 6255a22e45 into da335b95c4

pull/848/merge
Jamaic230 GitHub 7 years ago
parent
commit
5b3571768c
3 changed files with 15 additions and 6 deletions
  1. +9
    -2
      src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs
  2. +4
    -2
      src/Discord.Net.Commands/IModuleBase.cs
  3. +2
    -2
      src/Discord.Net.Commands/ModuleBase.cs

+ 9
- 2
src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs View File

@@ -201,7 +201,9 @@ namespace Discord.Commands
{
var instance = createInstance(services);
instance.SetContext(context);

Exception exc = null;
try
{
instance.BeforeExecute(cmd);
@@ -217,9 +219,14 @@ namespace Discord.Commands
return ExecuteResult.FromSuccess();
}
}
catch (Exception exception)
{
exc = exception;
throw;
}
finally
{
instance.AfterExecute(cmd);
instance.AfterExecute(cmd, exc);
(instance as IDisposable)?.Dispose();
}
}


+ 4
- 2
src/Discord.Net.Commands/IModuleBase.cs View File

@@ -1,4 +1,6 @@
namespace Discord.Commands
using System;

namespace Discord.Commands
{
internal interface IModuleBase
{
@@ -6,6 +8,6 @@

void BeforeExecute(CommandInfo command);
void AfterExecute(CommandInfo command);
void AfterExecute(CommandInfo command, Exception exception);
}
}

+ 2
- 2
src/Discord.Net.Commands/ModuleBase.cs View File

@@ -19,7 +19,7 @@ namespace Discord.Commands
{
}

protected virtual void AfterExecute(CommandInfo command)
protected virtual void AfterExecute(CommandInfo command, Exception exception)
{
}

@@ -32,6 +32,6 @@ namespace Discord.Commands

void IModuleBase.BeforeExecute(CommandInfo command) => BeforeExecute(command);

void IModuleBase.AfterExecute(CommandInfo command) => AfterExecute(command);
void IModuleBase.AfterExecute(CommandInfo command, Exception exception) => AfterExecute(command, exception);
}
}

Loading…
Cancel
Save