Search in sources :

Example 1 with AnnouncementCreatorResponse

use of com.cloudcraftgaming.discal.api.object.announcement.AnnouncementCreatorResponse in project DisCal-Discord-Bot by NovaFox161.

the class AnnouncementCreator method confirmAnnouncement.

/**
 * Confirms the announcement and enters it into the Database.
 * @param e The event received upon confirmation.
 * @return An AnnouncementCreatorResponse with detailed information.
 */
public AnnouncementCreatorResponse confirmAnnouncement(MessageReceivedEvent e) {
    if (hasAnnouncement(e.getGuild().getLongID())) {
        long guildId = e.getGuild().getLongID();
        Announcement a = getAnnouncement(guildId);
        if (a.hasRequiredValues()) {
            DatabaseManager.getManager().updateAnnouncement(a);
            terminate(e);
            return new AnnouncementCreatorResponse(true, a);
        }
    }
    return new AnnouncementCreatorResponse(false);
}
Also used : Announcement(com.cloudcraftgaming.discal.api.object.announcement.Announcement) AnnouncementCreatorResponse(com.cloudcraftgaming.discal.api.object.announcement.AnnouncementCreatorResponse)

Example 2 with AnnouncementCreatorResponse

use of com.cloudcraftgaming.discal.api.object.announcement.AnnouncementCreatorResponse in project DisCal-Discord-Bot by NovaFox161.

the class AnnouncementCommand method moduleConfirm.

private void moduleConfirm(MessageReceivedEvent event, GuildSettings settings) {
    long guildId = event.getGuild().getLongID();
    if (AnnouncementCreator.getCreator().hasAnnouncement(guildId)) {
        AnnouncementCreatorResponse acr = AnnouncementCreator.getCreator().confirmAnnouncement(event);
        if (acr.isSuccessful()) {
            if (acr.getAnnouncement().isEditing()) {
                if (acr.getAnnouncement().getCreatorMessage() != null) {
                    Message.deleteMessage(acr.getAnnouncement().getCreatorMessage());
                    Message.deleteMessage(event);
                }
                Message.sendMessage(AnnouncementMessageFormatter.getFormatAnnouncementEmbed(acr.getAnnouncement(), settings), MessageManager.getMessage("Creator.Announcement.Confirm.Edit.Success", settings), event);
            } else {
                if (acr.getAnnouncement().getCreatorMessage() != null) {
                    Message.deleteMessage(acr.getAnnouncement().getCreatorMessage());
                    Message.deleteMessage(event);
                }
                Message.sendMessage(AnnouncementMessageFormatter.getFormatAnnouncementEmbed(acr.getAnnouncement(), settings), MessageManager.getMessage("Creator.Announcement.Confirm.Create.Success", settings), event);
            }
        } else {
            if (AnnouncementCreator.getCreator().hasCreatorMessage(guildId)) {
                Message.deleteMessage(AnnouncementCreator.getCreator().getCreatorMessage(guildId));
                Message.deleteMessage(event);
                AnnouncementCreator.getCreator().setCreatorMessage(Message.sendMessage(AnnouncementMessageFormatter.getFormatAnnouncementEmbed(AnnouncementCreator.getCreator().getAnnouncement(guildId), settings), MessageManager.getMessage("Creator.Announcement.Confirm.Failure", settings), event));
            } else {
                Message.sendMessage(MessageManager.getMessage("Creator.Announcement.Confirm.Failure", settings), event);
            }
        }
    } else {
        Message.sendMessage(MessageManager.getMessage("Creator.Announcement.NotInit", settings), event);
    }
}
Also used : AnnouncementCreatorResponse(com.cloudcraftgaming.discal.api.object.announcement.AnnouncementCreatorResponse)

Aggregations

AnnouncementCreatorResponse (com.cloudcraftgaming.discal.api.object.announcement.AnnouncementCreatorResponse)2 Announcement (com.cloudcraftgaming.discal.api.object.announcement.Announcement)1