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