use of com.github.vaerys.commands.CommandObject in project DiscordSailv2 by Vaerys-Dawn.
the class ListModifs method getList.
public static XEmbedBuilder getList(CommandObject command) {
String title = "> Here are the Modifier roles you can choose from:";
List<String> list = command.guild.getModifierRoles().stream().map(iRole -> iRole.getName()).collect(Collectors.toList());
XEmbedBuilder builder = new XEmbedBuilder(command);
builder.withTitle(title);
builder.withDesc("```\n" + Utility.listFormatter(list, true) + "```\n" + get(ModifierRoles.class).missingArgs(command));
return builder;
}
use of com.github.vaerys.commands.CommandObject in project DiscordSailv2 by Vaerys-Dawn.
the class ListRoles method getList.
public static XEmbedBuilder getList(CommandObject command) {
String title = "> Here are the Cosmetic roles you can choose from:";
List<String> list = command.guild.getCosmeticRoles().stream().map(iRole -> iRole.getName()).collect(Collectors.toList());
XEmbedBuilder builder = new XEmbedBuilder(command);
builder.withTitle(title);
builder.withDesc("```\n" + Utility.listFormatter(list, true) + "```\n" + get(CosmeticRoles.class).missingArgs(command));
return builder;
}
use of com.github.vaerys.commands.CommandObject in project DiscordSailv2 by Vaerys-Dawn.
the class ArtHandler method checkList.
private static void checkList(CommandObject command) {
List<Long> pinnedMessages = command.guild.channelData.getPinnedMessages();
List<TrackLikes> likes = command.guild.channelData.getLikes();
List<IMessage> channelpins = RequestBuffer.request(() -> command.channel.get().getPinnedMessages()).get();
List<IMessage> markedForUnpin = new LinkedList<>();
int pinLimit = command.guild.config.pinLimit;
int tries = 0;
ListIterator iterator = pinnedMessages.listIterator();
List<Long> channelPinsLong = channelpins.stream().map(iMessage -> iMessage.getLongID()).collect(Collectors.toList());
try {
while (iterator.hasNext()) {
long item = (long) iterator.next();
if (!channelPinsLong.contains(item)) {
iterator.remove();
}
}
} catch (ConcurrentModificationException e) {
return;
}
while (pinnedMessages.size() > pinLimit && tries < 50) {
for (IMessage p : channelpins) {
if (pinnedMessages.contains(p.getLongID()) && pinnedMessages.get(0) == p.getLongID()) {
// adds the pin to the messages to be unpinned
markedForUnpin.add(p);
removePin(p, pinnedMessages);
}
}
tries++;
}
tries = 0;
for (IMessage message : markedForUnpin) {
try {
if (message.isPinned()) {
RequestBuffer.request(() -> command.channel.get().unpin(message)).get();
command.guild.sendDebugLog(command.setMessage(message), "ART_PINNED", "UNPIN", "PIN TOTAL = " + command.channel.getPinCount() + "/" + command.guild.config.pinLimit);
}
} catch (DiscordException e) {
if (!e.getMessage().contains("Message is not pinned!")) {
throw (e);
}
}
}
tries++;
iterator = likes.listIterator();
while (iterator.hasNext()) {
TrackLikes like = (TrackLikes) iterator.next();
if (!pinnedMessages.contains(like.getMessageID())) {
iterator.remove();
}
}
}
use of com.github.vaerys.commands.CommandObject in project DiscordSailv2 by Vaerys-Dawn.
the class UserInfo method execute.
@Override
public String execute(String args, CommandObject command) {
UserObject user;
if (args == null || args.isEmpty()) {
user = command.user;
} else {
user = Utility.getUser(command, args, true);
}
if (user == null) {
return "> Could not find user.";
}
ProfileObject profile = user.getProfile(command.guild);
if (profile == null && user.get().isBot()) {
if (user.get().getPresence().getStatus().equals(StatusType.OFFLINE) || user.get().getPresence().getStatus().equals(StatusType.UNKNOWN)) {
return "> Could not get a profile for " + user.displayName + ".";
}
profile = new ProfileObject(user.longID);
command.guild.users.addUser(profile);
} else if (profile == null) {
return "> Could not get a profile for " + user.displayName + ".";
}
if (!GuildHandler.testForPerms(command, Permissions.ADMINISTRATOR) && (user.isPrivateProfile(command.guild) && user.longID != command.user.longID)) {
return "> " + user.displayName + " has set their profile to private.";
}
// start of the profile builder.
XEmbedBuilder builder = new XEmbedBuilder(user);
List<IRole> roles = user.roles;
ArrayList<String> roleNames = new ArrayList<>();
ArrayList<String> links = new ArrayList<>();
// If user is a bot it will display the image below as the user avatar icon.
if (user.get().isBot()) {
builder.withAuthorIcon("http://i.imgur.com/aRJpAP4.png");
}
// sets title to user Display Name;
builder.withAuthorName(user.displayName);
// sets thumbnail to user Avatar.
builder.withThumbnail(user.get().getAvatarURL());
// gets the age of the account.
long nowUTC = ZonedDateTime.now(ZoneOffset.UTC).toEpochSecond();
ZonedDateTime creationDate = user.get().getCreationDate().atZone(ZoneId.systemDefault()).withZoneSameInstant(ZoneOffset.UTC);
long creationUTC = creationDate.toEpochSecond();
long difference = nowUTC - creationUTC;
// collect role names;
roleNames.addAll(roles.stream().filter(role -> !role.isEveryoneRole()).map(IRole::getName).collect(Collectors.toList()));
if (profile.getLinks() != null && profile.getLinks().size() > 0) {
links.addAll(profile.getLinks().stream().map(link -> link.toString()).collect(Collectors.toList()));
}
// builds desc
StringBuilder desc = new StringBuilder();
StringBuilder footer = new StringBuilder();
if (profile.getSettings().contains(UserSetting.READ_RULES) && command.guild.config.readRuleReward) {
builder.withFooterIcon(Constants.STICKER_STAR_URL);
// builder.withFooterIcon("https://emojipedia-us.s3.amazonaws.com/thumbs/120/twitter/120/glowing-star_1f31f.png");
}
if (command.guild.config.userInfoShowsDate) {
builder.withTimestamp(user.get().getCreationDate());
footer.append("UserID: " + profile.getUserID() + ", Creation Date");
// desc.append("**Account Created: **" + creationDate.format(formatter));
} else {
desc.append("**Account Created: **" + Utility.formatTimeDifference(difference));
footer.append("User ID: " + profile.getUserID());
}
builder.withFooterText(footer.toString());
desc.append("\n**Gender: **" + profile.getGender());
boolean showLevel = true;
boolean showCC = command.guild.config.moduleCC;
if (!command.guild.config.modulePixels || profile.getXP() == 0) {
showLevel = false;
}
if (showCC && !showLevel) {
desc.append("\n**Custom Commands: **" + command.guild.customCommands.getUserCommandCount(user, command.guild));
} else if (showLevel && !showCC) {
desc.append("\n**Level: **" + PixelHandler.xpToLevel(profile.getXP()));
} else if (showLevel && showCC) {
desc.append("\n**Custom Commands: **" + command.guild.customCommands.getUserCommandCount(user, command.guild) + indent + indent + indent + "**Level: **" + PixelHandler.xpToLevel(profile.getXP()));
}
desc.append("\n**Roles: **" + Utility.listFormatter(roleNames, true));
desc.append("\n\n*" + profile.getQuote() + "*");
desc.append("\n" + Utility.listFormatter(links, true));
if (user.isPatron) {
builder.withAuthorIcon(Constants.PATREON_ICON_URL);
}
builder.withDesc(desc.toString());
// sends Message
if (user.getProfile(command.guild).getSettings().contains(UserSetting.PRIVATE_PROFILE)) {
RequestHandler.sendEmbedMessage("", builder, command.user.get().getOrCreatePMChannel());
return "> Profile sent to your Direct messages.";
}
RequestHandler.sendEmbedMessage("", builder, command.channel.get());
return null;
}
use of com.github.vaerys.commands.CommandObject in project DiscordSailv2 by Vaerys-Dawn.
the class GuildToggle method validate.
public String validate() {
StringBuilder response = new StringBuilder();
boolean isError = false;
response.append(Utility.formatError(this));
String prefix;
if (isModule())
prefix = "Module";
else
prefix = "Setting";
if (name() == null) {
response.append(" > " + prefix + " type is empty.\n");
isError = true;
}
if (desc(new CommandObject()) == null || desc(new CommandObject()).isEmpty()) {
response.append(" > " + prefix + " description is empty.\n");
isError = true;
}
if (isError) {
return response.toString();
} else {
return null;
}
}
Aggregations