use of com.github.vaerys.objects.TimedEvent in project DiscordSailv2 by Vaerys-Dawn.
the class Globals method updateEvent.
public static void updateEvent() {
boolean eventFound = false;
for (TimedEvent e : events.getEvents()) {
e.sanitizeDates();
if (e.isEventActive()) {
eventFound = true;
currentEvent = e.getEventName();
}
}
if (eventFound == false) {
currentEvent = null;
}
}
use of com.github.vaerys.objects.TimedEvent 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);
}
}
use of com.github.vaerys.objects.TimedEvent in project DiscordSailv2 by Vaerys-Dawn.
the class Hello method execute.
@Override
public String execute(String args, CommandObject command) {
String message = "> Hello <user>.";
TimedEvent event = Globals.getCurrentEvent();
if (event != null && event.getHelloMessage() != null)
message = event.getHelloMessage();
if (command.user.longID == 153159020528533505L) {
message = message.replace("<user>", "Mother");
}
return message.replace("<user>", command.user.displayName);
}
use of com.github.vaerys.objects.TimedEvent in project DiscordSailv2 by Vaerys-Dawn.
the class EventSetup method execute.
@Override
public String execute(String args, CommandObject command) {
SplitFirstObject eventName = new SplitFirstObject(args);
TimedEvent event = null;
if (eventName.getFirstWord().equalsIgnoreCase("list")) {
XEmbedBuilder builder = new XEmbedBuilder(command);
builder.withTitle("All Events:");
String eventList = Utility.listFormatter(Globals.getEvents().stream().map(event1 -> event1.getEventName()).collect(Collectors.toList()), true);
builder.withDesc("```\n" + eventList + spacer + "```");
RequestHandler.sendEmbedMessage("", builder, command.channel.get());
return null;
}
if (eventName.getRest() == null) {
return "> Missing Mode.\n" + getModes();
}
for (TimedEvent t : Globals.getEvents()) {
if (t.getEventName().equalsIgnoreCase(eventName.getFirstWord())) {
event = t;
}
}
if (event == null && eventName.getRest().equalsIgnoreCase("Create")) {
Globals.getEvents().add(new TimedEvent(eventName.getFirstWord()));
return "> Event Created.";
} else {
SplitFirstObject mode = new SplitFirstObject(eventName.getRest());
if (event == null) {
return "> Event does not exist yet.";
}
String output = doModes(event, mode, command);
event.sanitizeDates();
Globals.updateEvent();
return output;
}
}
Aggregations