use of net.dv8tion.jda.api.events.interaction.SlashCommandEvent in project TJ-Bot by Together-Java.
the class TagManageCommandTest method triggerTagMessageCommand.
@NotNull
private SlashCommandEvent triggerTagMessageCommand(@NotNull TagManageCommand.Subcommand subcommand, @NotNull String tagId, @NotNull String messageId) {
SlashCommandEvent event = jdaTester.createSlashCommandEvent(command).setSubcommand(subcommand.getName()).setOption(TagManageCommand.ID_OPTION, tagId).setOption(TagManageCommand.MESSAGE_ID_OPTION, messageId).setUserWhoTriggered(moderator).build();
command.onSlashCommand(event);
return event;
}
use of net.dv8tion.jda.api.events.interaction.SlashCommandEvent in project TJ-Bot by Together-Java.
the class TagManageCommandTest method deleteUnknownTagFails.
@Test
@DisplayName("'/tag-manage delete' fails if the tag is unknown")
void deleteUnknownTagFails() {
// GIVEN a tag system without any tags
// WHEN using '/tag-manage delete id:foo'
SlashCommandEvent event = triggerDeleteCommand("foo");
// THEN the command fails and responds accordingly
verify(event).reply(startsWith("Could not find any tag with id"));
}
use of net.dv8tion.jda.api.events.interaction.SlashCommandEvent in project TJ-Bot by Together-Java.
the class TagManageCommandTest method triggerRawCommandWithUser.
@NotNull
private SlashCommandEvent triggerRawCommandWithUser(@NotNull String tagId, @NotNull Member user) {
SlashCommandEvent event = jdaTester.createSlashCommandEvent(command).setSubcommand(TagManageCommand.Subcommand.RAW.getName()).setOption(TagManageCommand.ID_OPTION, tagId).setUserWhoTriggered(user).build();
command.onSlashCommand(event);
return event;
}
use of net.dv8tion.jda.api.events.interaction.SlashCommandEvent in project TJ-Bot by Together-Java.
the class TagManageCommandTest method deleteExistingTagWorks.
@Test
@DisplayName("'/tag-manage delete' works if the tag is known")
void deleteExistingTagWorks() {
// GIVEN a tag system with the "foo" tag
system.putTag("foo", "bar");
// WHEN using '/tag-manage delete id:foo'
SlashCommandEvent event = triggerDeleteCommand("foo");
// THEN the command succeeds and the tag was deleted
assertEquals("Success", getResponse(event).getTitle());
assertFalse(system.hasTag("foo"));
}
use of net.dv8tion.jda.api.events.interaction.SlashCommandEvent in project TJ-Bot by Together-Java.
the class TagManageCommandTest method createWithMessageGenericErrorFails.
@Test
@DisplayName("'/tag-manage create-with-message' fails if there is a generic error (such as a network failure)")
void createWithMessageGenericErrorFails() {
// GIVEN a tag system without any tags and a generic network failure
failOnRetrieveMessage("1", new IOException("Generic network failure"));
// WHEN using '/tag-manage create-with-message id:foo message-id:1'
SlashCommandEvent event = triggerCreateWithMessageCommand("foo", "1");
// THEN the command fails and responds accordingly, the tag was not created
verify(event).reply(startsWith("Something unexpected went wrong"));
assertFalse(system.hasTag("foo"));
}
Aggregations