mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-03-21 20:59:05 +00:00
added initial version containing ping/echo command and first draft of the command handling structure
This commit is contained in:
15
abstracto-application/command/command-base/support/pom.xml
Normal file
15
abstracto-application/command/command-base/support/pom.xml
Normal 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>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user