Search in sources :

Example 1 with AbstractWidgetAction

use of net.robinfriedli.aiode.command.widget.AbstractWidgetAction in project aiode by robinfriedli.

the class HistoryInterceptor method performChained.

@Override
public void performChained(Command command) {
    CommandContext context = command.getContext();
    CommandHistory history = new CommandHistory();
    long currentTimeMillis = System.currentTimeMillis();
    history.setStartMillis(currentTimeMillis);
    history.setTimestamp(LocalDateTime.ofInstant(Instant.ofEpochMilli(currentTimeMillis), ZoneId.systemDefault()));
    history.setCommandContextId(command.getContext().getId());
    history.setCommandIdentifier(command.getIdentifier());
    history.setWidget(command instanceof AbstractWidgetAction);
    history.setCommandBody(command instanceof AbstractCommand ? ((AbstractCommand) command).getCommandInput() : command.getCommandBody());
    history.setInput(command instanceof AbstractCommand ? context.getMessage().getContentDisplay() : command.getCommandBody());
    history.setGuild(context.getGuild().getName());
    history.setGuildId(context.getGuild().getId());
    history.setUser(context.getUser().getName());
    history.setUserId(context.getUser().getId());
    context.setCommandHistory(history);
}
Also used : CommandHistory(net.robinfriedli.aiode.entities.CommandHistory) CommandContext(net.robinfriedli.aiode.command.CommandContext) AbstractCommand(net.robinfriedli.aiode.command.AbstractCommand) AbstractWidgetAction(net.robinfriedli.aiode.command.widget.AbstractWidgetAction)

Aggregations

AbstractCommand (net.robinfriedli.aiode.command.AbstractCommand)1 CommandContext (net.robinfriedli.aiode.command.CommandContext)1 AbstractWidgetAction (net.robinfriedli.aiode.command.widget.AbstractWidgetAction)1 CommandHistory (net.robinfriedli.aiode.entities.CommandHistory)1