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