use of net.dv8tion.jda.api.interactions.commands.OptionMapping in project Ninbot by Nincodedo.
the class PollCommandTest method parsePollMessage.
@Test
void parsePollMessage() {
Member member = Mockito.mock(Member.class);
TextChannel textChannel = Mockito.mock(TextChannel.class);
Guild guild = Mockito.mock(Guild.class);
OptionMapping choice1 = Mockito.mock(OptionMapping.class);
OptionMapping choice2 = Mockito.mock(OptionMapping.class);
OptionMapping choice3 = Mockito.mock(OptionMapping.class);
OptionMapping questionOption = Mockito.mock(OptionMapping.class);
when(slashCommandEvent.getChannel()).thenReturn(textChannel);
when(slashCommandEvent.getGuild()).thenReturn(guild);
when(slashCommandEvent.getOption("choice1")).thenReturn(choice1);
when(slashCommandEvent.getOption("choice2")).thenReturn(choice2);
when(slashCommandEvent.getOptions()).thenReturn(List.of(choice3));
when(choice3.getName()).thenReturn("choice3");
when(choice3.getAsString()).thenReturn("3rd");
when(slashCommandEvent.getOption("question")).thenReturn(questionOption);
when(questionOption.getAsString()).thenReturn("test");
when(slashCommandEvent.getOption("userchoices")).thenReturn(null);
when(slashCommandEvent.getOption("polllength")).thenReturn(null);
when(guild.getId()).thenReturn("1");
when(textChannel.getId()).thenReturn("1");
when(member.getEffectiveAvatarUrl()).thenReturn("http://avatarturl.com/avatar.png");
when(member.getEffectiveName()).thenReturn("Nincodedo");
var poll = pollCommand.parsePollMessage(slashCommandEvent, member);
assertThat(poll.getChoices()).isNotEmpty();
assertThat(poll.getChoices()).hasSize(3);
assertThat(poll.getTitle()).isEqualTo("test");
}
use of net.dv8tion.jda.api.interactions.commands.OptionMapping in project Ninbot by Nincodedo.
the class PollCommandTest method executePollCommand.
@Test
void executePollCommand() {
Member member = Mockito.mock(Member.class);
TextChannel textChannel = Mockito.mock(TextChannel.class);
Guild guild = Mockito.mock(Guild.class);
ReplyCallbackAction replyAction = Mockito.mock(ReplyCallbackAction.class);
OptionMapping choice1 = Mockito.mock(OptionMapping.class);
OptionMapping choice2 = Mockito.mock(OptionMapping.class);
OptionMapping questionOption = Mockito.mock(OptionMapping.class);
when(slashCommandEvent.getChannel()).thenReturn(textChannel);
when(slashCommandEvent.getGuild()).thenReturn(guild);
when(slashCommandEvent.getMember()).thenReturn(member);
when(slashCommandEvent.getOption("choice1")).thenReturn(choice1);
when(slashCommandEvent.getOption("choice2")).thenReturn(choice2);
when(slashCommandEvent.getOption("question")).thenReturn(questionOption);
when(slashCommandEvent.reply(any(Message.class))).thenReturn(replyAction);
when(choice1.getAsString()).thenReturn("1st");
when(choice2.getAsString()).thenReturn("2nd");
when(questionOption.getAsString()).thenReturn("why?");
when(guild.getId()).thenReturn("1");
when(textChannel.getId()).thenReturn("1");
when(member.getEffectiveAvatarUrl()).thenReturn("http://google.com/a-url");
when(guild.getLocale()).thenReturn(Locale.ENGLISH);
var actualMessageAction = pollCommand.execute(slashCommandEvent);
assertThat(actualMessageAction).isNotNull();
assertThat(actualMessageAction.getReactions()).isEmpty();
}
use of net.dv8tion.jda.api.interactions.commands.OptionMapping in project LightboltMeeting by LightboltMeeting.
the class StartMeetingSubcommand method handleMeetingCommand.
@Override
protected ReplyCallbackAction handleMeetingCommand(SlashCommandInteractionEvent event, LocaleConfig locale, SystemsConfig.MeetingConfig config, MeetingRepository repo) throws SQLException {
OptionMapping idOption = event.getOption("meeting-id");
if (idOption == null) {
return Responses.error(event, locale.getCommand().getMISSING_ARGUMENTS());
}
int id = (int) idOption.getAsLong();
Optional<Meeting> meetingOptional = repo.getById(id);
if (meetingOptional.isEmpty()) {
return Responses.error(event, String.format(locale.getMeeting().getCommand().getMEETING_NOT_FOUND(), id));
}
Meeting meeting = meetingOptional.get();
if (!MeetingManager.canEditMeeting(meeting, event.getUser().getIdLong())) {
return Responses.error(event, locale.getMeeting().getMEETING_NO_PERMISSION());
}
Bot.meetingStateManager.cancelMeetingSchedule(meeting);
new MeetingManager(event.getJDA(), meeting).startMeeting(event.getUser());
var com = locale.getMeeting().getCommand();
return Responses.success(event, com.getMEETING_START_SUCCESS_TITLE(), String.format(com.getMEETING_START_SUCCESS_DESCRIPTION(), meeting.getTitle()));
}
use of net.dv8tion.jda.api.interactions.commands.OptionMapping in project LightboltMeeting by LightboltMeeting.
the class EditMeetingSubcommand method handleMeetingCommand.
@Override
protected ReplyCallbackAction handleMeetingCommand(SlashCommandInteractionEvent event, LocaleConfig locale, SystemsConfig.MeetingConfig config, MeetingRepository repo) throws SQLException {
OptionMapping idOption = event.getOption("meeting-id");
if (idOption == null) {
return Responses.error(event, locale.getCommand().getMISSING_ARGUMENTS());
}
int id = (int) idOption.getAsLong();
Optional<Meeting> meetingOptional = repo.getById(id);
if (meetingOptional.isEmpty()) {
return Responses.error(event, String.format(locale.getMeeting().getCommand().getMEETING_NOT_FOUND(), id));
}
Meeting meeting = meetingOptional.get();
if (!MeetingManager.canEditMeeting(meeting, event.getUser().getIdLong())) {
return Responses.error(event, locale.getMeeting().getMEETING_NO_PERMISSION());
}
this.buildEditModal(event, meeting, locale).queue();
return null;
}
use of net.dv8tion.jda.api.interactions.commands.OptionMapping in project TamaBot by Loli-Cafe.
the class LickPussyCommand method compose.
@Override
public void compose(SlashCommandInteractionEvent event) {
checkContext(event.getMember(), event.getTextChannel());
OptionMapping optionMapping = event.getOption("user");
if (optionMapping == null)
throw new CommandException(getUsage());
event.replyEmbeds(execute(String.format("%s gaping %s pussy", event.getUser().getAsMention(), optionMapping.getAsUser().getAsMention()))).queue();
}
Aggregations