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();
}
});
}
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()));
}
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;
}
Aggregations