Search in sources :

Example 1 with RaidExistsException

use of pokeraidbot.domain.errors.RaidExistsException in project pokeraidbot by magnusmickelsson.

the class RaidRepository method newRaid.

public Raid newRaid(User raidCreator, Raid raid, Guild guild, Config config, String rawMessage) {
    RaidEntity raidEntity = getActiveOrFallbackToExRaidEntity(raid.getGym(), raid.getRegion());
    if (raidEntity != null) {
        if ((raidEntity.isExRaid() && !raid.isExRaid()) || (!raidEntity.isExRaid() && raid.isExRaid())) {
        // This is a situation we should allow, in case Niantic now allows for raids to happen at EX gyms
        } else {
            throw new RaidExistsException(raidCreator, getRaidInstance(raidEntity), localeService, localeService.getLocaleForUser(raidCreator));
        }
    }
    final Raid raidInstance = getRaidInstance(saveRaid(raidCreator, raid));
    trackingService.notifyTrackers(guild, raidInstance, config, raidCreator, rawMessage);
    return raidInstance;
}
Also used : RaidEntity(pokeraidbot.infrastructure.jpa.raid.RaidEntity) RaidExistsException(pokeraidbot.domain.errors.RaidExistsException)

Aggregations

RaidExistsException (pokeraidbot.domain.errors.RaidExistsException)1 RaidEntity (pokeraidbot.infrastructure.jpa.raid.RaidEntity)1