added templating support

changed ping command to use templates
added userjoin/userleave event
added guild to command context
refactored post target service
added logging output to initial loading
added server_id to postTarget
added leave log postTarget
This commit is contained in:
Sheldan
2020-03-16 01:28:17 +01:00
parent 5c6b7b9a78
commit 0521a1ab44
30 changed files with 491 additions and 34 deletions

View File

@@ -1,20 +1,32 @@
package dev.sheldan.abstracto.command.utility;
import dev.sheldan.abstracto.command.Command;
import dev.sheldan.abstracto.command.Module;
import dev.sheldan.abstracto.command.execution.Configuration;
import dev.sheldan.abstracto.command.execution.Context;
import dev.sheldan.abstracto.command.execution.Result;
import dev.sheldan.abstracto.templating.TemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
@Service
public class Ping implements Command {
public static final String PING_TEMPLATE = "ping";
@Autowired
private TemplateService templateService;
@Override
@Transactional
public Result execute(Context context) {
long ping = context.getJda().getGatewayPing();
context.getChannel().sendMessage("Latency: " + ping + " ms.").queue();
HashMap<String, Object> parameters = new HashMap<>();
parameters.put("latency", ping);
String text = templateService.renderTemplate(PING_TEMPLATE, parameters);
context.getChannel().sendMessage(text).queue();
return Result.fromSuccess();
}