use of com.github.vaerys.objects.SplitFirstObject in project DiscordSailv2 by Vaerys-Dawn.
the class SetLevel method execute.
@Override
public String execute(String args, CommandObject command) {
SplitFirstObject xpArgs = new SplitFirstObject(args);
UserObject user = Utility.getUser(command, xpArgs.getFirstWord(), false);
if (user == null) {
return "> Could not find user.";
}
try {
long level = Long.parseLong(xpArgs.getRest());
if (level > Constants.LEVEL_CAP)
return "> No... " + level + " Is way too many levels. Im not setting your level that high.";
long xp = PixelHandler.totalXPForLevel(level);
ProfileObject userObject = user.getProfile(command.guild);
if (userObject == null) {
return "> User does not have a profile.";
}
if (Utility.testUserHierarchy(user, command.user, command.guild)) {
return "> You do not have permission to edit " + user.displayName + "'s pixels.";
}
userObject.setXp(xp);
userObject.removeLevelFloor();
GuildHandler.checkUsersRoles(user.longID, command.guild);
return "> " + user.displayName + "'s Level is now set to: **" + level + "**";
} catch (NumberFormatException e) {
return "> Invalid number";
}
}
use of com.github.vaerys.objects.SplitFirstObject in project DiscordSailv2 by Vaerys-Dawn.
the class SetQuote method execute.
@Override
public String execute(String args, CommandObject command) {
UserObject user = command.user;
String quote = args;
boolean adminEdit = false;
if (ADMIN_EDIT.isSubCommand(command)) {
if (GuildHandler.testForPerms(command, Permissions.MANAGE_MESSAGES)) {
SplitFirstObject userCall = new SplitFirstObject(quote);
user = Utility.getUser(command, userCall.getFirstWord(), false, true);
if (user == null)
return "> Could not find user.";
quote = userCall.getRest();
adminEdit = true;
} else {
return command.user.notAllowed;
}
}
int maxLength = 140;
if (user.isPatron) {
maxLength += 140;
}
ProfileObject u = user.getProfile(command.guild);
quote = Utility.removeFun(quote);
if (quote == null || quote.isEmpty())
return "> You can't have an empty quote.";
for (String s : quote.split(" ")) {
if (!Utility.checkURL(s)) {
return "> Cannot add quote. Malicious link found.";
}
}
if (adminEdit) {
if (quote.length() > maxLength) {
return "> Quote is too long...\n(must be under " + maxLength + " chars)";
}
u.setQuote(quote);
return "> " + user.displayName + "'s Quote Edited.";
} else {
if (quote.length() > maxLength) {
return "> Your Quote is too long...\n(must be under " + maxLength + " chars)";
}
u.setQuote(quote);
return "> Quote Edited.";
}
}
use of com.github.vaerys.objects.SplitFirstObject in project DiscordSailv2 by Vaerys-Dawn.
the class Respond method execute.
@Override
public String execute(String args, CommandObject command) {
SplitFirstObject response = new SplitFirstObject(args);
IUser recipient = command.client.get().getUserByID(Utility.stringLong(response.getFirstWord()));
return sendDM(response.getRest(), command, recipient, command.user.username + ": ");
}
use of com.github.vaerys.objects.SplitFirstObject in project DiscordSailv2 by Vaerys-Dawn.
the class EditLinks method execute.
@Override
public String execute(String args, CommandObject command) {
UserObject user = command.user;
SplitFirstObject userCall = new SplitFirstObject(args);
boolean adminEdit = false;
if (GuildHandler.testForPerms(command, ADMIN_EDIT.getPermissions()) || GuildHandler.canBypass(command.user.get(), command.guild.get())) {
user = Utility.getUser(command, userCall.getFirstWord(), false);
if (user != null && userCall.getRest() != null && user.getProfile(command.guild) != null) {
adminEdit = true;
} else {
user = command.user;
}
}
SplitFirstObject linkName;
if (adminEdit) {
linkName = new SplitFirstObject(userCall.getRest());
} else {
linkName = new SplitFirstObject(args);
}
ProfileObject userObject = user.getProfile(command.guild);
if (userObject == null) {
return "> " + user.displayName + " Has not Spoken yet thus they have nothing to edit.";
}
userObject.setLinks();
for (UserLinkObject link : userObject.getLinks()) {
if (link.getName().equalsIgnoreCase(linkName.getFirstWord())) {
userObject.getLinks().remove(link);
if (adminEdit) {
return "> " + user.displayName + "'s Link was removed.";
} else {
return "> Link removed.";
}
}
}
int maxLinks = 5;
if (user.isPatron) {
maxLinks += 5;
}
if (linkName.getRest() == null) {
return "> Cannot add link, Must specify a URL.";
} else {
if (userObject.getLinks().size() >= maxLinks) {
if (adminEdit) {
return "> " + user.displayName + " already has " + maxLinks + " links, a link must be removed to add a new one.";
} else {
return "> You already have " + maxLinks + " links, you must remove one to add a new one.";
}
}
if (linkName.getFirstWord().length() > 15) {
return "> Link Name too long. (Max 15 chars)";
}
if (Utility.checkURL(linkName.getRest())) {
try {
new URL(linkName.getRest());
userObject.getLinks().add(new UserLinkObject(linkName.getFirstWord(), linkName.getRest()));
if (adminEdit) {
return "> New link added for " + user.displayName + ".";
} else {
return "> New link added.";
}
} catch (MalformedURLException e) {
return "> Cannot add link, Invalid URL.";
}
} else {
return "> Cannot add link, Invalid URL.";
}
}
}
use of com.github.vaerys.objects.SplitFirstObject in project DiscordSailv2 by Vaerys-Dawn.
the class NewDailyMessage method execute.
@Override
public String execute(String args, CommandObject command) {
try {
SplitFirstObject day = new SplitFirstObject(args);
DayOfWeek dayOfWeek = DayOfWeek.valueOf(day.getFirstWord().toUpperCase());
if (day.getRest() != null) {
IMessage working = RequestHandler.sendMessage("`Working...`", command.channel.get()).get();
QueueHandler.addToQueue(command, day.getRest(), dayOfWeek, Constants.QUEUE_DAILY);
RequestHandler.deleteMessage(working);
return "> Request Sent.";
} else {
return Utility.getCommandInfo(this, command);
}
} catch (IllegalArgumentException e) {
return "> Not a valid Day of the week.";
}
}
Aggregations