use of net.dv8tion.jda.api.events.interaction.SlashCommandEvent in project TJ-Bot by Together-Java.
the class TagManageCommandTest method createWithMessageFailsForInvalidMessageId.
@Test
@DisplayName("'/tag-manage create-with-message' fails if the given message id is in an invalid format")
void createWithMessageFailsForInvalidMessageId() {
// GIVEN a tag system without any tags
// WHEN using '/tag-manage create-with-message id:foo message-id:bar'
SlashCommandEvent event = triggerCreateWithMessageCommand("foo", "bar");
// THEN the command fails and responds accordingly, the tag was not created
verify(event).reply("The given message id 'bar' is invalid, expected a number.");
assertFalse(system.hasTag("foo"));
}
use of net.dv8tion.jda.api.events.interaction.SlashCommandEvent in project TJ-Bot by Together-Java.
the class TagManageCommandTest method createWithMessageTagThatAlreadyExistsFails.
@Test
@DisplayName("'/tag-manage create-with-message' fails if the tag is known")
void createWithMessageTagThatAlreadyExistsFails() {
// GIVEN a tag system with the "foo" tag and a message with id and content
system.putTag("foo", "old");
postMessage("new", "1");
// 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 is still there and unchanged
verify(event).reply("The tag with id 'foo' already exists.");
assertTrue(system.hasTag("foo"));
assertEquals("old", system.getTag("foo").orElseThrow());
}
use of net.dv8tion.jda.api.events.interaction.SlashCommandEvent in project TJ-Bot by Together-Java.
the class TagManageCommandTest method triggerDeleteCommand.
@NotNull
private SlashCommandEvent triggerDeleteCommand(@NotNull String tagId) {
SlashCommandEvent event = jdaTester.createSlashCommandEvent(command).setSubcommand(TagManageCommand.Subcommand.DELETE.getName()).setOption(TagManageCommand.ID_OPTION, tagId).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 editUnknownTagFails.
@Test
@DisplayName("'/tag-manage edit' fails if the tag is unknown")
void editUnknownTagFails() {
// GIVEN a tag system without any tags
// WHEN using '/tag-manage edit id:foo content:new'
SlashCommandEvent event = triggerEditCommand("foo", "new");
// THEN the command fails and responds accordingly, the tag was not created
verify(event).reply(startsWith("Could not find any tag with id"));
assertFalse(system.hasTag("foo"));
}
use of net.dv8tion.jda.api.events.interaction.SlashCommandEvent in project TJ-Bot by Together-Java.
the class TagManageCommandTest method createTagThatAlreadyExistsFails.
@Test
@DisplayName("'/tag-manage create' fails if the tag already exists")
void createTagThatAlreadyExistsFails() {
// GIVEN a tag system with the "foo" tag
system.putTag("foo", "old");
// WHEN using '/tag-manage create id:foo content:new'
SlashCommandEvent event = triggerCreateCommand("foo", "new");
// THEN the command fails and responds accordingly, the tag is still there and unchanged
verify(event).reply("The tag with id 'foo' already exists.");
assertTrue(system.hasTag("foo"));
assertEquals("old", system.getTag("foo").orElseThrow());
}
Aggregations