Add Javacord test

This commit is contained in:
tueem 2024-11-01 16:07:18 +01:00
parent 9d81522429
commit 9f87f47b1f
No known key found for this signature in database
GPG Key ID: 819A0F7C36B9CF07
2 changed files with 53 additions and 0 deletions

@ -0,0 +1,25 @@
package net.tomatentum.marinara.test;
import org.javacord.api.DiscordApi;
import org.javacord.api.DiscordApiBuilder;
import org.junit.jupiter.api.Test;
import net.tomatentum.marinara.Marinara;
import net.tomatentum.marinare.wrapper.javacord.JavacordWrapper;
public class SlashCommandTest {
String DISCORD_TOKEN = System.getenv("DISCORD_TEST_TOKEN");
@Test
public void testSlashCommand() {
DiscordApi api = new DiscordApiBuilder()
.setToken(DISCORD_TOKEN)
.login().join();
Marinara marinara = Marinara.load(new JavacordWrapper(api));
marinara.getRegistry().addInteractions(new TestCommand());
marinara.getRegistry().registerCommands();
System.out.println("done");
}
}

@ -0,0 +1,28 @@
package net.tomatentum.marinara.test;
import org.javacord.api.interaction.SlashCommandInteraction;
import net.tomatentum.marinara.interaction.InteractionHandler;
import net.tomatentum.marinara.interaction.commands.annotation.SlashCommand;
import net.tomatentum.marinara.interaction.commands.annotation.SlashCommandOption;
import net.tomatentum.marinara.interaction.commands.option.SlashCommandOptionType;
public class TestCommand implements InteractionHandler {
@SlashCommand(
name = "test",
description = "testingen",
serverIds = {
1037753048602255440L
},
options = {
@SlashCommandOption(
name = "pommes",
description = "mit Fett",
type = SlashCommandOptionType.MENTIONABLE
)
}
)
public void exec(SlashCommandInteraction interaction) {
System.out.println("Success!");
}
}