use of com.github.vaerys.templates.Command 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.templates.Command in project DiscordSailv2 by Vaerys-Dawn.
the class GuildObject method removeCommandsByType.
public void removeCommandsByType(SAILType type) {
ListIterator iterator = commands.listIterator();
while (iterator.hasNext()) {
Command c = (Command) iterator.next();
if (c.type == type) {
logger.trace("Command: " + c.names[0] + " removed.");
iterator.remove();
}
}
for (SAILType t : commandTypes) {
if (t == type) {
logger.trace("Type: " + t.toString() + " removed.");
commandTypes.remove(t);
return;
}
}
}
use of com.github.vaerys.templates.Command 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.templates.Command in project DiscordSailv2 by Vaerys-Dawn.
the class InfoDM method execute.
@Override
public String execute(String args, CommandObject command) {
List<Command> commands = command.guild.getAllCommands(command);
if (command.user.longID == command.client.creator.longID) {
commands.addAll(Globals.getCreatorCommands(true));
}
String error = "> Could not find information on any commands named **" + args + "**.";
for (Command c : commands) {
for (String s : c.names) {
if (args.equalsIgnoreCase(s)) {
// if (!Utility.testForPerms(c.perms(), command.user.getToggles(), command.guild.getToggles())) {
// return error;
// }
RequestHandler.sendEmbedMessage("", c.getCommandInfo(command), command.channel.get());
return "";
}
}
}
return error;
// List<Command> commands = Utility.getCommandsByType(Globals.getAllCommands(), command, TYPE_DM,
// true);
//
// for (Command c : commands) {
// for (String s : c.names()) {
// if (args.equalsIgnoreCase(s)) {
// XEmbedBuilder infoEmbed = new XEmbedBuilder();
//
// //command info
// StringBuilder builder = new StringBuilder();
// builder.append("**" + Globals.defaultPrefixCommand + c.names()[0]);
// if (c.usage() != null) {
// builder.append(" " + c.usage());
// }
// builder.append("**\nDesc: **" + c.description() + "**\n");
// builder.append("Type: **" + c.type() + "**\n");
// if (c.type().equals(DMCommand.TYPE_CREATOR)) {
// builder.append("**" + ownerOnly + "**");
// }
// infoEmbed.appendField("> Info - " + c.names()[0], builder.toString(), false);
//
// //aliases
// if (c.names().length > 1) {
// StringBuilder aliasBuilder = new StringBuilder();
// for (int i = 1; i < c.names().length; i++) {
// aliasBuilder.append(Globals.defaultPrefixCommand + c.names()[i] + ", ");
// }
// aliasBuilder.delete(aliasBuilder.length() - 2, aliasBuilder.length());
// aliasBuilder.append(".\n");
// infoEmbed.appendField("Aliases:", aliasBuilder.toString(), false);
// }
// Utility.sendEmbedMessage("", infoEmbed, command.channel.getToggles());
// return "";
// }
// }
// }
// return "> Command with the name " + args + " not found.";
}
Aggregations