added initial version containing ping/echo command and first draft of the command handling structure

This commit is contained in:
Sheldan
2019-12-09 23:50:24 +01:00
parent 78a4d814ad
commit 42cfe33b3a
41 changed files with 1023 additions and 1 deletions

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>command-base</artifactId>
<groupId>dev.sheldan.abstracto.command</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>support</artifactId>
</project>

View File

@@ -0,0 +1,38 @@
package dev.sheldan.abstracto.command.support;
import dev.sheldan.abstracto.command.Command;
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.command.meta.CommandRegistry;
import net.dv8tion.jda.api.EmbedBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class Help implements Command {
@Autowired
private CommandRegistry registry;
@Override
public Result execute(Context context) {
EmbedBuilder builder = new EmbedBuilder();
registry.getAllCommands().forEach(command -> {
builder.addField(command.getConfiguration().getName(), command.getConfiguration().getDescription(), false);
});
context.getChannel().sendMessage(builder.build()).queue();
return Result.fromSuccess();
}
@Override
public Configuration getConfiguration() {
return Configuration.builder()
.name("help")
.module("utility")
.description("Prints the help")
.causesReaction(false)
.build();
}
}