mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-07 18:03:50 +00:00
[AB-340] adding timestamp support for serverInfo command
This commit is contained in:
@@ -26,6 +26,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
@Slf4j
|
||||
public class ServerInfo extends AbstractConditionableCommand {
|
||||
|
||||
public static final String SERVERINFO_RESPONSE_TEMPLATE_KEY = "serverinfo_response";
|
||||
@Autowired
|
||||
private ChannelService channelService;
|
||||
|
||||
@@ -34,13 +35,14 @@ public class ServerInfo extends AbstractConditionableCommand {
|
||||
log.info("Displaying serverinfo for server {}", commandContext.getGuild().getId());
|
||||
ServerInfoModel model = buildModel(commandContext);
|
||||
return FutureUtils.toSingleFutureGeneric(
|
||||
channelService.sendEmbedTemplateInTextChannelList("serverinfo_response", model, commandContext.getChannel()))
|
||||
channelService.sendEmbedTemplateInTextChannelList(SERVERINFO_RESPONSE_TEMPLATE_KEY, model, commandContext.getChannel()))
|
||||
.thenApply(aVoid -> CommandResult.fromIgnored());
|
||||
}
|
||||
|
||||
private ServerInfoModel buildModel(CommandContext commandContext) {
|
||||
ServerInfoModel model = (ServerInfoModel) ContextConverter.fromCommandContext(commandContext, ServerInfoModel.class);
|
||||
model.setGuild(commandContext.getGuild());
|
||||
model.setTimeCreated(commandContext.getGuild().getTimeCreated().toInstant());
|
||||
List<EmoteDisplay> staticEmotes = new ArrayList<>();
|
||||
List<EmoteDisplay> animatedEmotes = new ArrayList<>();
|
||||
commandContext.getGuild().getEmotes().forEach(emote -> {
|
||||
|
||||
@@ -7,6 +7,7 @@ import lombok.Setter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@@ -14,6 +15,7 @@ import java.util.List;
|
||||
@SuperBuilder
|
||||
public class ServerInfoModel extends UserInitiatedServerContext {
|
||||
private Guild guild;
|
||||
private Instant timeCreated;
|
||||
private List<EmoteDisplay> staticEmotes;
|
||||
private List<EmoteDisplay> animatedEmotes;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user