Search in sources :

Example 11 with Meeting

use of de.lightbolt.meeting.systems.meeting.model.Meeting in project LightboltMeeting by LightboltMeeting.

the class MeetingStartJob method execute.

@Override
public void execute(JobExecutionContext context) {
    String[] jobDetail = context.getJobDetail().getKey().getName().split("-");
    DbHelper.doDaoAction(MeetingRepository::new, dao -> {
        Optional<Meeting> meetingOptional = dao.getById(Integer.parseInt(jobDetail[0]));
        if (meetingOptional.isEmpty()) {
            log.warn("Meeting doesn't exist, cannot execute start job.");
            return;
        }
        Meeting meeting = meetingOptional.get();
        if (meeting.getStatus() != MeetingStatus.ONGOING) {
            var manager = new MeetingManager(Bot.jda, meeting);
            manager.startMeeting();
        }
    });
}
Also used : MeetingManager(de.lightbolt.meeting.systems.meeting.MeetingManager) Meeting(de.lightbolt.meeting.systems.meeting.model.Meeting) MeetingRepository(de.lightbolt.meeting.systems.meeting.dao.MeetingRepository)

Example 12 with Meeting

use of de.lightbolt.meeting.systems.meeting.model.Meeting 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()));
}
Also used : OptionMapping(net.dv8tion.jda.api.interactions.commands.OptionMapping) MeetingManager(de.lightbolt.meeting.systems.meeting.MeetingManager) Meeting(de.lightbolt.meeting.systems.meeting.model.Meeting)

Example 13 with Meeting

use of de.lightbolt.meeting.systems.meeting.model.Meeting 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;
}
Also used : OptionMapping(net.dv8tion.jda.api.interactions.commands.OptionMapping) Meeting(de.lightbolt.meeting.systems.meeting.model.Meeting)

Aggregations

Meeting (de.lightbolt.meeting.systems.meeting.model.Meeting)13 MeetingManager (de.lightbolt.meeting.systems.meeting.MeetingManager)9 MeetingRepository (de.lightbolt.meeting.systems.meeting.dao.MeetingRepository)5 OptionMapping (net.dv8tion.jda.api.interactions.commands.OptionMapping)4 SystemsConfig (de.lightbolt.meeting.data.config.SystemsConfig)3 LocaleConfig (de.lightbolt.meeting.utils.localization.LocaleConfig)3 Arrays (java.util.Arrays)3 Responses (de.lightbolt.meeting.command.Responses)2 MeetingSubcommand (de.lightbolt.meeting.systems.meeting.MeetingSubcommand)2 SQLException (java.sql.SQLException)2 Optional (java.util.Optional)2 SlashCommandInteractionEvent (net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent)2 ReplyCallbackAction (net.dv8tion.jda.api.requests.restaction.interactions.ReplyCallbackAction)2 Bot (de.lightbolt.meeting.Bot)1 DbHelper (de.lightbolt.meeting.data.h2db.DbHelper)1 LocalizationUtils (de.lightbolt.meeting.utils.localization.LocalizationUtils)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1