Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Old Code
- @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()) {
- 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<>();
- //init booleans
- boolean showCC = command.guild.config.moduleCC;
- boolean showLevel = !command.guild.config.modulePixels || profile.getXP() == 0;
- //sets title to user Display Name;
- builder.withAuthorName(user.displayName);
- //sets thumbnail to user Avatar.
- builder.withThumbnail(user.avatarURL);
- //gets the age of the account.
- long difference = 0;
- if (user.get() != null) {
- long nowUTC = ZonedDateTime.now(ZoneOffset.UTC).toEpochSecond();
- ZonedDateTime creationDate = user.get().getCreationDate().atZone(ZoneId.systemDefault()).withZoneSameInstant(ZoneOffset.UTC);
- long creationUTC = creationDate.toEpochSecond();
- 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);
- }
- if (command.guild.config.userInfoShowsDate && user.get() != null) {
- builder.withTimestamp(user.get().getCreationDate());
- footer.append("UserID: " + profile.getUserID() + ", Creation Date");
- } else {
- if (difference != 0) {
- desc.append("**Account Created: **" + Utility.formatTimeDifference(difference));
- }
- footer.append("User ID: " + profile.getUserID());
- }
- builder.withFooterText(footer.toString());
- //append gender
- desc.append("\n**Gender: **" + profile.getGender());
- //append cc count and level
- if (showCC || showLevel) desc.append("\n");
- if (showCC) desc.append(String.format("**Custom Commands:** %d", user.customCommands.size()));
- if (showLevel) {
- if (showCC) desc.append(indent + indent + indent);
- desc.append(String.format("**Level: **", PixelHandler.xpToLevel(profile.getXP())));
- }
- //append roles
- if (roleNames.size() != 0) desc.append("\n**Roles: **" + Utility.listFormatter(roleNames, true));
- desc.append("\n\n");
- //append quote
- if (!profile.getQuote().isEmpty()) desc.append("*" + profile.getQuote() + "*");
- //append links
- if (links.size() != 0) desc.append(Utility.listFormatter(links, true));
- //set author Icon
- if (user.longID == 153159020528533505L) {
- builder.withAuthorIcon(Constants.DEV_IMAGE_URL);
- builder.withAuthorUrl(Constants.LINK_GITHUB);
- } else if (user.isPatron) builder.withAuthorIcon(Constants.PATREON_ICON_URL);
- //bots only
- if (user.isBot) builder.withAuthorIcon(Constants.BOT_USER_URL);
- if (user.get() == null){
- builder.withAuthorIcon(Constants.UNKNOWN_USER_URL);
- }
- //add desc
- 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;
- }
- // New Code
- @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);
- //init bot profile
- if (profile == null && user.get().isBot()) {
- profile = new ProfileObject(user.longID);
- command.guild.users.addUser(profile);
- } else if (profile == null) {
- return "> Could not get a profile for " + user.displayName + ".";
- }
- //private profile check
- 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;
- List<String> roleNames = roles.stream().filter(role -> !role.isEveryoneRole()).map(IRole::getName).collect(Collectors.toList());
- List<String> links = profile.getLinks().stream().map(link -> link.toString()).collect(Collectors.toList());
- long accountAge = user.getAccountAgeSeconds();
- boolean showCC = command.guild.config.moduleCC;
- boolean showLevel = command.guild.config.modulePixels && profile.getXP() != 0;
- StringBuilder desc = new StringBuilder();
- //sets title to user Display Name;
- builder.withAuthorName(user.displayName);
- //sets thumbnail to user Avatar.
- builder.withThumbnail(user.avatarURL);
- //set author Icon
- if (user.longID == 153159020528533505L) {
- builder.withAuthorIcon(Constants.DEV_IMAGE_URL);
- builder.withAuthorUrl(Constants.LINK_GITHUB);
- } else if (user.isPatron) builder.withAuthorIcon(Constants.PATREON_ICON_URL);
- //bots only
- if (user.isBot) builder.withAuthorIcon(Constants.BOT_USER_URL);
- if (user.get() == null) {
- builder.withAuthorIcon(Constants.UNKNOWN_USER_URL);
- }
- //append sticker
- if (profile.getSettings().contains(UserSetting.READ_RULES) && command.guild.config.readRuleReward) {
- builder.withFooterIcon(Constants.STICKER_STAR_URL);
- }
- //build desc desc
- if (command.guild.config.userInfoShowsDate) {
- builder.withTimestamp(user.creationDate);
- builder.withFooterText("UserID: " + profile.getUserID() + ", Creation Date");
- } else {
- desc.append("**Account Created: **" + Utility.formatTimeDifference(accountAge));
- builder.withFooterText("User ID: " + profile.getUserID());
- }
- //append gender
- desc.append("\n**Gender: **" + profile.getGender());
- //append cc count and level
- if (showCC || showLevel) desc.append("\n");
- if (showCC) desc.append(String.format("**Custom Commands:** %d", user.customCommands.size()));
- if (showLevel) {
- if (showCC) desc.append(indent + indent + indent);
- desc.append(String.format("**Level:** %d", PixelHandler.xpToLevel(profile.getXP())));
- }
- //append roles
- if (roleNames.size() != 0) desc.append("\n**Roles: **" + Utility.listFormatter(roleNames, true));
- desc.append("\n\n");
- //append quote
- if (!profile.getQuote().isEmpty()) desc.append("*" + profile.getQuote() + "*");
- //append links
- if (links.size() != 0) desc.append(Utility.listFormatter(links, true));
- //add desc
- 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment