use of net.dv8tion.jda.api.events.interaction.SlashCommandEvent in project TJ-Bot by Together-Java.
the class TagCommandTest method triggerSlashCommand.
@NotNull
private SlashCommandEvent triggerSlashCommand(@NotNull String id, @Nullable Member userToReplyTo) {
SlashCommandEventBuilder builder = jdaTester.createSlashCommandEvent(command).setOption(TagCommand.ID_OPTION, id);
if (userToReplyTo != null) {
builder.setOption(TagCommand.REPLY_TO_USER_OPTION, userToReplyTo);
}
SlashCommandEvent event = builder.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 createWithMessageUnknownMessageFails.
@Test
@DisplayName("'/tag-manage create-with-message' fails if the linked message is unknown")
void createWithMessageUnknownMessageFails() {
// GIVEN a tag system without any tags and an unknown message id
failOnRetrieveMessage("1", jdaTester.createErrorResponseException(ErrorResponse.UNKNOWN_MESSAGE));
// 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("The message with id '1' does not exist.");
assertFalse(system.hasTag("foo"));
}
use of net.dv8tion.jda.api.events.interaction.SlashCommandEvent in project TJ-Bot by Together-Java.
the class TagManageCommandTest method createWithMessageNewTagWorks.
@Test
@DisplayName("'/tag-manage create-with-message' works if the tag is new")
void createWithMessageNewTagWorks() {
// GIVEN a tag system without any tags and a message with id and content
postMessage("bar", "1");
// WHEN using '/tag-manage create-with-message id:foo message-id:1'
SlashCommandEvent event = triggerCreateWithMessageCommand("foo", "1");
// THEN the command succeeds and the system contains the tag
assertEquals("Success", getResponse(event).getTitle());
assertTrue(system.hasTag("foo"));
assertEquals("bar", system.getTag("foo").orElseThrow());
}
use of net.dv8tion.jda.api.events.interaction.SlashCommandEvent in project TJ-Bot by Together-Java.
the class TagManageCommandTest method createNewTagWorks.
@Test
@DisplayName("'/tag-manage create' works if the tag is new")
void createNewTagWorks() {
// GIVEN a tag system without any tags
// WHEN using '/tag-manage create id:foo content:bar'
SlashCommandEvent event = triggerCreateCommand("foo", "bar");
// THEN the command succeeds and the system contains the tag
assertEquals("Success", getResponse(event).getTitle());
assertTrue(system.hasTag("foo"));
assertEquals("bar", system.getTag("foo").orElseThrow());
}
use of net.dv8tion.jda.api.events.interaction.SlashCommandEvent in project TJ-Bot by Together-Java.
the class TagManageCommandTest method editWithMessageExistingTagWorks.
@Test
@DisplayName("'/tag-manage edit-with-message' works if the tag is known")
void editWithMessageExistingTagWorks() {
// GIVEN a tag system with the "foo" tag
system.putTag("foo", "old");
postMessage("new", "1");
// WHEN using '/tag-manage edit-with-message id:foo message-id:1'
SlashCommandEvent event = triggerEditWithMessageCommand("foo", "1");
// THEN the command succeeds and the content of the tag was changed
assertEquals("Success", getResponse(event).getTitle());
assertEquals("new", system.getTag("foo").orElseThrow());
}
Aggregations