mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-05 09:00:24 +00:00
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:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user