use of com.github.vaerys.objects.CompObject in project DiscordSailv2 by Vaerys-Dawn.
the class EnterComp method execute.
@Override
public String execute(String args, CommandObject command) {
GuildConfig guildconfig = command.guild.config;
IMessage message = command.message.get();
IUser author = command.user.get();
if (guildconfig.compEntries) {
String fileName;
String fileUrl;
if (message.getAttachments().size() > 0) {
List<IMessage.Attachment> attatchments = message.getAttachments();
IMessage.Attachment a = attatchments.get(0);
fileName = a.getFilename();
fileUrl = a.getUrl();
} else if (!args.isEmpty()) {
fileName = author.getName() + "'s Entry";
fileUrl = args;
} else {
return "> Missing a File or Image link to enter into the competition.";
}
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yy - HH:mm:ss");
Calendar cal = Calendar.getInstance();
command.guild.competition.newEntry(new CompObject(author.getDisplayName(command.guild.get()), author.getLongID(), fileName, fileUrl, dateFormat.format(cal.getTime())));
return "> Thank you " + author.getDisplayName(command.guild.get()) + " For entering the Competition.";
} else {
return "> Competition Entries are closed.";
}
}
use of com.github.vaerys.objects.CompObject in project DiscordSailv2 by Vaerys-Dawn.
the class GetCompEntries method execute.
@Override
public String execute(String args, CommandObject command) {
if (command.guild.competition.getEntries().size() == 0) {
return "> No entries were found.";
}
List<CompObject> compObjects = command.guild.competition.getEntries();
for (int i = 0; i < compObjects.size(); i++) {
XEmbedBuilder builder = new XEmbedBuilder(command);
builder.withTitle("Entry " + (i + 1));
IUser user = command.guild.getUserByID(compObjects.get(i).getUserID());
if (user != null) {
builder.withDesc(user.mention());
builder.withColor(GuildHandler.getUsersColour(user, command.guild.get()));
}
if (Utility.isImageLink(compObjects.get(i).getFileUrl())) {
builder.withThumbnail(compObjects.get(i).getFileUrl());
} else {
if (user != null) {
builder.withDesc(user.mention() + "\n" + compObjects.get(i).getFileUrl());
} else {
builder.withDesc(compObjects.get(i).getFileUrl());
}
}
builder.send(command.channel);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
Utility.sendStack(e);
}
}
return "";
}
use of com.github.vaerys.objects.CompObject in project DiscordSailv2 by Vaerys-Dawn.
the class RemoveEntry method execute.
@Override
public String execute(String args, CommandObject command) {
try {
int entry = Integer.parseInt(args) - 1;
CompObject didRemove = command.guild.competition.getEntries().remove(entry);
return "> Removed entry " + (entry + 1) + "\n<" + didRemove.getFileUrl() + ">";
} catch (NumberFormatException e) {
return "> Needs a valid number";
} catch (IndexOutOfBoundsException e) {
return "> Could not find entry";
}
}
Aggregations