mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-03-27 14:23:56 +00:00
added error message logging to reaction post execution
added validation to post target command added templates for post target command moved ping and echo model to interface added show emote command
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
package dev.sheldan.abstracto.utility.command;
|
||||
|
||||
import dev.sheldan.abstracto.command.Command;
|
||||
import dev.sheldan.abstracto.command.HelpInfo;
|
||||
import dev.sheldan.abstracto.command.execution.*;
|
||||
import dev.sheldan.abstracto.templating.TemplateService;
|
||||
import dev.sheldan.abstracto.utility.Utility;
|
||||
import dev.sheldan.abstracto.utility.models.template.ShowEmoteLog;
|
||||
import net.dv8tion.jda.api.entities.Emote;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class ShowEmote implements Command {
|
||||
|
||||
private static final String SHOW_EMOTE_RESPONSE_TEMPLATE = "showEmote_response";
|
||||
|
||||
@Autowired
|
||||
private TemplateService templateService;
|
||||
|
||||
@Override
|
||||
public Result execute(CommandContext commandContext) {
|
||||
List<Object> parameters = commandContext.getParameters().getParameters();
|
||||
Object emoteParameter = parameters.get(0);
|
||||
if(!(emoteParameter instanceof Emote)) {
|
||||
return Result.fromError("No custom emote found.");
|
||||
}
|
||||
Emote emote = (Emote) emoteParameter;
|
||||
ShowEmoteLog emoteLog = (ShowEmoteLog) ContextConverter.fromCommandContext(commandContext, ShowEmoteLog.class);
|
||||
emoteLog.setEmote(emote);
|
||||
String message = templateService.renderTemplate(SHOW_EMOTE_RESPONSE_TEMPLATE, emoteLog);
|
||||
commandContext.getChannel().sendMessage(message).queue();
|
||||
return Result.fromSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandConfiguration getConfiguration() {
|
||||
List<Parameter> parameters = new ArrayList<>();
|
||||
parameters.add(Parameter.builder().name("emote").type(Emote.class).optional(false).build());
|
||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
||||
return CommandConfiguration.builder()
|
||||
.name("showEmote")
|
||||
.module(Utility.UTILITY)
|
||||
.templated(true)
|
||||
.causesReaction(false)
|
||||
.parameters(parameters)
|
||||
.help(helpInfo)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
Retrieves the URL to the given emote.
|
||||
@@ -0,0 +1 @@
|
||||
Shows the URL and the name of the given emote.
|
||||
@@ -0,0 +1 @@
|
||||
**Name**: ${emote.name} **Link**: ${emote.imageUrl}
|
||||
@@ -0,0 +1 @@
|
||||
showEmote <emote>
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.sheldan.abstracto.utility.models.template;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.UserInitiatedServerContext;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import net.dv8tion.jda.api.entities.Emote;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@SuperBuilder
|
||||
public class ShowEmoteLog extends UserInitiatedServerContext {
|
||||
private Emote emote;
|
||||
}
|
||||
@@ -7,7 +7,9 @@ import lombok.Setter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
|
||||
@Getter @Setter @SuperBuilder
|
||||
@Getter
|
||||
@Setter
|
||||
@SuperBuilder
|
||||
public class SuggestionLog extends UserInitiatedServerContext {
|
||||
private Suggestion suggestion;
|
||||
private Member suggester;
|
||||
|
||||
Reference in New Issue
Block a user