Search in sources :

Example 1 with TimedEvent

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;
    }
}
Also used : TimedEvent(com.github.vaerys.objects.TimedEvent)

Example 2 with TimedEvent

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

Example 3 with TimedEvent

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);
}
Also used : TimedEvent(com.github.vaerys.objects.TimedEvent)

Example 4 with TimedEvent

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;
    }
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) TimedEvent(com.github.vaerys.objects.TimedEvent) SplitFirstObject(com.github.vaerys.objects.SplitFirstObject)

Aggregations

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