Add and use interaction command hooks for BeforeExecute, AfterExecute, OnException and GetExceptionResponse
This commit is contained in:
parent
9a2bf84a05
commit
24749d9009
3 changed files with 43 additions and 7 deletions
|
@ -40,8 +40,23 @@ namespace Geekbot.Core.Interactions
|
|||
{
|
||||
var type = _commands[interaction.Data.Name];
|
||||
var command = (InteractionBase)Activator.CreateInstance(type);
|
||||
|
||||
return await command.Exec(interaction);
|
||||
|
||||
InteractionResponse response;
|
||||
command.BeforeExecute();
|
||||
try
|
||||
{
|
||||
response = await command.Exec(interaction);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
command.OnException(e);
|
||||
response = command.GetExceptionResponse();
|
||||
}
|
||||
finally
|
||||
{
|
||||
command.AfterExecute();
|
||||
}
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue