Search in sources :

Example 1 with EventAvatar

use of com.github.vaerys.objects.EventAvatar in project DiscordSailv2 by Vaerys-Dawn.

the class Client method handleAvatars.

public static void handleAvatars() {
    TimedEvent event = Globals.getCurrentEvent();
    ZonedDateTime timeNow = ZonedDateTime.now(ZoneOffset.UTC);
    String dailyFileName = Globals.dailyAvatarName.replace("#day#", timeNow.getDayOfWeek().toString());
    File avatarFile;
    // sets Avatar.
    if (Globals.doDailyAvatars) {
        avatarFile = new File(Constants.DIRECTORY_GLOBAL_IMAGES + dailyFileName);
    } else {
        avatarFile = new File(Constants.DIRECTORY_GLOBAL_IMAGES + Globals.defaultAvatarFile);
    }
    Image avatar = Image.forFile(avatarFile);
    if (event != null && event.doRotateAvatars()) {
        EventAvatar eventAvatar = event.getAvatarDay(timeNow.getDayOfWeek());
        if (eventAvatar != null) {
            avatar = Image.forUrl(FilenameUtils.getExtension(eventAvatar.getLink()), eventAvatar.getLink());
        }
    }
    RequestHandler.updateAvatar(avatar);
    // wait for the avatar to update properly
    try {
        Thread.sleep(3000);
    } catch (InterruptedException e) {
        Utility.sendStack(e);
    }
}
Also used : ZonedDateTime(java.time.ZonedDateTime) EventAvatar(com.github.vaerys.objects.EventAvatar) TimedEvent(com.github.vaerys.objects.TimedEvent) Image(sx.blah.discord.util.Image) File(java.io.File)

Aggregations

EventAvatar (com.github.vaerys.objects.EventAvatar)1 TimedEvent (com.github.vaerys.objects.TimedEvent)1 File (java.io.File)1 ZonedDateTime (java.time.ZonedDateTime)1 Image (sx.blah.discord.util.Image)1