Search in sources :

Example 1 with SlashCommandEvent

use of net.dv8tion.jda.api.events.interaction.SlashCommandEvent in project TJ-Bot by Together-Java.

the class TagCommandTest method canNotFindTagSuggestDifferentTag.

@Test
@DisplayName("Respond that the tag could not be found but suggest a different tag instead, if the system has a different tag registered")
void canNotFindTagSuggestDifferentTag() {
    // GIVEN a system with the tag "first" registered
    system.putTag("first", "foo");
    // WHEN triggering the slash command '/tag id:second'
    SlashCommandEvent event = triggerSlashCommand("second", null);
    // THEN responds that the tag could not be found and instead suggests using the other tag
    verify(event).reply("Could not find any tag with id 'second', did you perhaps mean 'first'?");
}
Also used : SlashCommandEvent(net.dv8tion.jda.api.events.interaction.SlashCommandEvent) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 2 with SlashCommandEvent

use of net.dv8tion.jda.api.events.interaction.SlashCommandEvent in project TJ-Bot by Together-Java.

the class TagCommandTest method canNotFindTagInEmptySystem.

@Test
@DisplayName("Respond that the tag could not be found if the system has no tags registered yet")
void canNotFindTagInEmptySystem() {
    // GIVEN a system without any tags registered
    // WHEN triggering the slash command '/tag id:first'
    SlashCommandEvent event = triggerSlashCommand("first", null);
    // THEN responds that the tag could not be found
    verify(event).reply("Could not find any tag with id 'first'.");
}
Also used : SlashCommandEvent(net.dv8tion.jda.api.events.interaction.SlashCommandEvent) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 3 with SlashCommandEvent

use of net.dv8tion.jda.api.events.interaction.SlashCommandEvent in project TJ-Bot by Together-Java.

the class TagCommandTest method canFindTheTagAndRespondWithContent.

@Test
@DisplayName("Respond with the tags content if the tag could be found")
void canFindTheTagAndRespondWithContent() {
    // GIVEN a system with the tag "first" registered
    system.putTag("first", "foo");
    // WHEN triggering the slash command '/tag id:first'
    SlashCommandEvent event = triggerSlashCommand("first", null);
    // THEN finds the tag and responds with its content
    verify(event).replyEmbeds(any(MessageEmbed.class));
}
Also used : MessageEmbed(net.dv8tion.jda.api.entities.MessageEmbed) SlashCommandEvent(net.dv8tion.jda.api.events.interaction.SlashCommandEvent) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 4 with SlashCommandEvent

use of net.dv8tion.jda.api.events.interaction.SlashCommandEvent in project TJ-Bot by Together-Java.

the class TagManageCommandTest method rawTagCanNotFindUnknownTag.

@Test
@DisplayName("'/tag-manage raw' can not be used on unknown tags")
void rawTagCanNotFindUnknownTag() {
    // GIVEN a tag system without any tags
    // WHEN using '/tag-manage raw id:unknown'
    SlashCommandEvent event = triggerRawCommand("unknown");
    // THEN the command can not find the tag and responds accordingly
    verify(event).reply(startsWith("Could not find any tag"));
}
Also used : SlashCommandEvent(net.dv8tion.jda.api.events.interaction.SlashCommandEvent) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 5 with SlashCommandEvent

use of net.dv8tion.jda.api.events.interaction.SlashCommandEvent in project TJ-Bot by Together-Java.

the class TagManageCommandTest method triggerTagContentCommand.

@NotNull
private SlashCommandEvent triggerTagContentCommand(@NotNull TagManageCommand.Subcommand subcommand, @NotNull String tagId, @NotNull String content) {
    SlashCommandEvent event = jdaTester.createSlashCommandEvent(command).setSubcommand(subcommand.getName()).setOption(TagManageCommand.ID_OPTION, tagId).setOption(TagManageCommand.CONTENT_OPTION, content).setUserWhoTriggered(moderator).build();
    command.onSlashCommand(event);
    return event;
}
Also used : SlashCommandEvent(net.dv8tion.jda.api.events.interaction.SlashCommandEvent) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

SlashCommandEvent (net.dv8tion.jda.api.events.interaction.SlashCommandEvent)35 Test (org.junit.jupiter.api.Test)24 DisplayName (org.junit.jupiter.api.DisplayName)23 NotNull (org.jetbrains.annotations.NotNull)8 Collectors (java.util.stream.Collectors)3 Member (net.dv8tion.jda.api.entities.Member)3 IOException (java.io.IOException)2 List (java.util.List)2 Consumer (java.util.function.Consumer)2 TechDiscordBot (me.TechsCode.TechDiscordBot.TechDiscordBot)2 DefinedQuery (me.TechsCode.TechDiscordBot.objects.DefinedQuery)2 Query (me.TechsCode.TechDiscordBot.objects.Query)2 TechEmbedBuilder (me.TechsCode.TechDiscordBot.util.TechEmbedBuilder)2 Permission (net.dv8tion.jda.api.Permission)2 Guild (net.dv8tion.jda.api.entities.Guild)2 MessageEmbed (net.dv8tion.jda.api.entities.MessageEmbed)2 OptionType (net.dv8tion.jda.api.interactions.commands.OptionType)2 OptionData (net.dv8tion.jda.api.interactions.commands.build.OptionData)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2