Create your bot discord more easily with Modulo. Allows you to add features easily with modules. You can see it as a minecraft server with plugins. Modulo will load the modules you added in the modules folder.
<repository>
<url>"http://nexus.aytronn.com/repository/aydustries/"</url>
</repository>
- Artifact Information:
<dependency>
<groupId>fr.aytronn</groupId>
<artifactId>modulo-api</artifactId>
<version>latest</version>
</dependency>
Or alternatively, with Gradle:
- Repository:
repositories {
maven {
url = uri("http://nexus.aytronn.com/repository/aydustries/")
}
}
dependencies {
compileOnly("fr.aytronn:modulo-api:latest")
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(19))
}
public class Example extends IModule {
private static Example instance;
@Override
public void onEnable() {
instance = this;
getLogger().info("Starting Example...");
registerListeners();
registerCommands();
}
@Override
public void onDisable() {
getLogger().info("Shutdown Example...");
}
public void registerListeners() {
registerListener(new ExampleListener());
}
public void registerCommands() {
registerCommand(new ExampleCommand());
}
public void registerActions() {
registerAction(new ExampleAction());
}
public static Example getInstance() {
return instance;
}
}
public class ExampleCommand {
@Command(name = "plexfth.clear", subCommandObject = {"nbMessage"}, subCommandType = {SlashCommandOptionType.DECIMAL}, description = "Clear the channel")
public void clearCommand(CommandArgs arg) {
//Do some code for clear the channel
//Mandatory to respond to the command
arg.reply("Clear command");
}
}
public class ExampleAction {
public ExampleAction(TextChannel channel) {
new MessageBuilder()
.setContent("Content example")
.addComponents(ActionRow.of(
Button.success("start@@args1@@args2@@...", "Start example")
)).send(channel);
}
@Command(customId = "start")
public void action(ActionArgs args) {
//Do some code for clear the channel
System.out.println(args.getArgs().get(0)); //Will print "args1"
System.out.println(args.getArgs().get(1)); //Will print "args2"
System.out.println(args.getArgs().get(2)); //Will print "..."
//Mandatory to respond to the action
arg.reply("Start action");
}
}
public class ExampleListener implements MessageCreateListener {
@Override
public void onMessageCreate(MessageCreateEvent event) {
event.getChannel().sendMessage("Thank you for message! <@" + event.getMessageAuthor().getIdAsString() + ">");
}
}
For more information, see the wiki of Javacord this is the api I use to make the CoreBot. For the module loader the code comes from @HookWoods