Search in sources :

Example 26 with SplitFirstObject

use of com.github.vaerys.objects.SplitFirstObject 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

SplitFirstObject (com.github.vaerys.objects.SplitFirstObject)26 UserObject (com.github.vaerys.masterobjects.UserObject)10 ProfileObject (com.github.vaerys.objects.ProfileObject)10 IRole (sx.blah.discord.handle.obj.IRole)5 DayOfWeek (java.time.DayOfWeek)4 IChannel (sx.blah.discord.handle.obj.IChannel)4 XEmbedBuilder (com.github.vaerys.objects.XEmbedBuilder)3 IMessage (sx.blah.discord.handle.obj.IMessage)3 CCommandObject (com.github.vaerys.objects.CCommandObject)2 DailyMessage (com.github.vaerys.objects.DailyMessage)2 RewardRoleObject (com.github.vaerys.objects.RewardRoleObject)2 IUser (sx.blah.discord.handle.obj.IUser)2 UserSetting (com.github.vaerys.enums.UserSetting)1 MessageHandler (com.github.vaerys.handlers.MessageHandler)1 StringHandler (com.github.vaerys.handlers.StringHandler)1 CharacterObject (com.github.vaerys.objects.CharacterObject)1 JoinMessage (com.github.vaerys.objects.JoinMessage)1 TimedEvent (com.github.vaerys.objects.TimedEvent)1 UserLinkObject (com.github.vaerys.objects.UserLinkObject)1 TagObject (com.github.vaerys.templates.TagObject)1