use of com.github.vaerys.objects.CCommandObject in project DiscordSailv2 by Vaerys-Dawn.
the class GetCCData method execute.
@Override
public String execute(String args, CommandObject command) {
for (CCommandObject c : command.guild.customCommands.getCommandList()) {
if (c.getName().equalsIgnoreCase(args)) {
StringBuilder content = new StringBuilder("Command Name: \"" + c.getName() + "\"");
IUser createdBy = command.guild.getUserByID(c.getUserID());
if (createdBy == null)
createdBy = command.client.get().fetchUser(c.getUserID());
if (createdBy == null)
content.append("\nCreated by: \"null\"");
else
content.append("\nCreated by: \"" + createdBy.getName() + "#" + createdBy.getDiscriminator() + "\"");
content.append("\nTimes run: \"" + c.getTimesRun() + "\"");
content.append("\nContents: \"" + c.getContents(false) + "\"");
String filePath = Constants.DIRECTORY_TEMP + command.message.longID + ".txt";
FileHandler.writeToFile(filePath, content.toString(), false);
RequestHandler.sendFile("> Here is the raw data for Custom Command: **" + c.getName() + "**", new File(filePath), command.channel.get());
try {
Thread.sleep(4000);
new File(filePath).delete();
} catch (InterruptedException e) {
Utility.sendStack(e);
}
return "";
}
}
return "> Custom command " + args + " could not be found.";
// return command.customCommands.sendCCasJSON(command.channelSID, args);
}
use of com.github.vaerys.objects.CCommandObject in project DiscordSailv2 by Vaerys-Dawn.
the class InfoCC method execute.
@Override
public String execute(String args, CommandObject command) {
CCommandObject customCommand = command.guild.customCommands.getCommand(args);
if (customCommand == null) {
return Constants.ERROR_CC_NOT_FOUND;
}
StringBuilder builder = new StringBuilder();
XEmbedBuilder embedBuilder = new XEmbedBuilder(command);
String title = "> Here is the information for command: **" + customCommand.getName() + "**\n";
IUser createdBy = command.guild.getUserByID(customCommand.getUserID());
if (createdBy == null)
createdBy = command.client.get().fetchUser(customCommand.getUserID());
if (createdBy == null)
builder.append("Creator: **Null**\n");
else
builder.append("Creator: **@" + createdBy.getName() + "#" + createdBy.getDiscriminator() + "**\n");
builder.append("Time Run: **" + customCommand.getTimesRun() + "**\n");
builder.append("Is Locked: **" + customCommand.isLocked() + "**\n");
builder.append("Is ShitPost: **" + customCommand.isShitPost() + "**");
embedBuilder.appendField(title, builder.toString(), false);
RequestHandler.sendEmbedMessage("", embedBuilder, command.channel.get());
return null;
}
use of com.github.vaerys.objects.CCommandObject in project DiscordSailv2 by Vaerys-Dawn.
the class ListCCs method listCommands.
public String listCommands(int page, CommandObject command) {
ArrayList<String> pages = new ArrayList<>();
int counter = 0;
int totalCCs = 0;
ArrayList<String> list = new ArrayList<>();
XEmbedBuilder builder = new XEmbedBuilder(command);
for (CCommandObject c : command.guild.customCommands.getCommandList()) {
if (counter > 15) {
pages.add("```" + Utility.listFormatter(list, true) + "```");
list.clear();
counter = 0;
}
list.add(command.guild.config.getPrefixCC() + c.getName());
totalCCs++;
counter++;
}
pages.add("`" + Utility.listFormatter(list, true) + "`");
try {
String title = "> Here is Page **" + page + "/" + pages.size() + "** of Custom Commands:";
builder.appendField(title, pages.get(page - 1), false);
builder.withFooterText("Total Custom Commands stored on this Server: " + totalCCs);
RequestHandler.sendEmbedMessage("", builder, command.channel.get());
return null;
} catch (IndexOutOfBoundsException e) {
return "> That Page does not exist.";
}
}
use of com.github.vaerys.objects.CCommandObject in project DiscordSailv2 by Vaerys-Dawn.
the class TransferCC method execute.
@Override
public String execute(String args, CommandObject command) {
String filePath = Constants.DIRECTORY_OLD_FILES + command.guild.longID + "_CustomCommands.json";
IGuild guild = command.guild.get();
IUser author = command.user.get();
IChannel channel = command.channel.get();
CustomCommands customCommands = command.guild.customCommands;
if (Paths.get(filePath).toFile().exists()) {
com.github.vaerys.oldcode.CustomCommands oldCommands = null;
if (oldCommands == null) {
oldCommands = (com.github.vaerys.oldcode.CustomCommands) FileHandler.readFromJson(filePath, com.github.vaerys.oldcode.CustomCommands.class);
}
CCommandObject transfering = oldCommands.convertCommand(args);
if (transfering == null) {
return Constants.ERROR_CC_NOT_FOUND;
}
boolean locked = transfering.isLocked();
long userID = transfering.getUserID();
if (guild.getUserByID(userID) == null) {
RequestHandler.sendMessage("> This command's old owner no longer is part of this server.\n" + Constants.PREFIX_INDENT + author.getDisplayName(guild) + " will become the new owner of this command.\n" + "> I am now attempting to transfer the command over.", channel);
userID = author.getLongID();
} else {
RequestHandler.sendMessage("> I am now attempting to transfer " + guild.getUserByID(userID).getDisplayName(guild) + "'s command.", channel);
}
String name = transfering.getName();
String contents = transfering.getContents(false);
contents = contents.replace("#author!#", "#username#");
boolean shitpost = transfering.isShitPost();
command.setAuthor(Globals.getClient().getUserByID(userID));
return customCommands.addCommand(locked, name, contents, shitpost, command);
} else {
return "> Your Server has no Legacy commands to transfer.";
}
}
Aggregations