use of sx.blah.discord.handle.obj.IPresence in project DiscordSailv2 by Vaerys-Dawn.
the class GroupUp method execute.
@Override
public String execute(String args, CommandObject command) {
String presence = null;
if (!args.isEmpty()) {
presence = args;
}
ArrayList<GroupUpObject> list = command.guild.channelData.getGroupUpObjects();
for (GroupUpObject g : list) {
if (command.user.longID == g.getUserID()) {
list.remove(g);
return "> You have been removed from the list.";
}
}
list.add(new GroupUpObject(presence, command.user.longID));
// person added to list :D
ArrayList<String> completeList = new ArrayList<>();
for (GroupUpObject g : list) {
IUser user = command.client.get().getUserByID(g.getUserID());
if (user != null) {
IPresence userPres = user.getPresence();
if (!userPres.getStatus().equals(StatusType.DND) && !userPres.getStatus().equals(StatusType.OFFLINE) && !userPres.getStatus().equals(StatusType.UNKNOWN)) {
if (g.getPresence() != null || userPres.getText().isPresent()) {
String newPres;
if (g.getPresence() == null) {
newPres = userPres.getText().get();
} else {
newPres = g.getPresence();
}
StringBuilder builder = new StringBuilder(newPres);
if (builder.length() > 40) {
builder.delete(0, 40);
builder.append("...");
}
completeList.add(indent + user.mention() + " Playing: " + builder.toString());
} else {
completeList.add(indent + user.mention());
}
}
}
}
return "**> You have been added to the GroupUp list.**\n\n" + "Here are the others currently waiting:\n" + Utility.listFormatter(completeList, false) + "\n*To opt out simply run this command again*\n" + Utility.getCommandInfo(this, command);
}
Aggregations