use of com.github.vaerys.objects.XEmbedBuilder in project DiscordSailv2 by Vaerys-Dawn.
the class QueueHandler method addToQueue.
public static void addToQueue(CommandObject object, String content, DayOfWeek dayOfWeek, String type) {
ReactionEmoji thumbsUp = Utility.getReaction(Constants.EMOJI_APPROVE);
ReactionEmoji thumbsDown = Utility.getReaction(Constants.EMOJI_DISAPPROVE);
IChannel channel = object.client.get().getChannelByID(Globals.queueChannelID);
if (channel != null) {
switch(type) {
case Constants.QUEUE_DAILY:
long uID = Globals.getDailyMessages().newDailyMsgUID();
if (uID == -1) {
object.client.creator.sendDm("> Max limit of Daily messages hit.");
break;
}
XEmbedBuilder embedBuilder = new XEmbedBuilder(object);
embedBuilder.withAuthorName("New Daily Message - " + object.guild.get().getName());
embedBuilder.withFooterText(object.user.longID + "");
embedBuilder.withTitle(object.user.username);
embedBuilder.withDesc(content);
embedBuilder.appendField(dowString, dayOfWeek + "", true);
embedBuilder.appendField(uIDString, uID + "", true);
IMessage message = RequestHandler.sendEmbedMessage("", embedBuilder, channel).get();
RequestBuffer.request(() -> message.addReaction(thumbsUp)).get();
RequestBuffer.request(() -> message.addReaction(thumbsDown)).get();
Globals.getDailyMessages().getQueue().add(new QueueObject(message.getLongID(), uID, type));
checkQueue();
return;
default:
return;
}
}
}
use of com.github.vaerys.objects.XEmbedBuilder in project DiscordSailv2 by Vaerys-Dawn.
the class RequestHandler method sendEmbededImage.
public static RequestBuffer.RequestFuture<IMessage> sendEmbededImage(String s, String imageUrl, IChannel channel) {
XEmbedBuilder builder = new XEmbedBuilder(Constants.pixelColour);
builder.withImage(imageUrl);
if (s.length() > 2000) {
sendError("Could not send message, Too Large.", s, channel);
return null;
}
if (!Utility.isImageLink(imageUrl)) {
sendError("Could not send Embed, link is not a valid image URL", imageUrl, channel);
return null;
}
return RequestBuffer.request(() -> {
if (s == null || s.isEmpty()) {
return channel.sendMessage(builder.build());
}
return channel.sendMessage(s, builder.build());
});
}
use of com.github.vaerys.objects.XEmbedBuilder 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.XEmbedBuilder 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.XEmbedBuilder in project DiscordSailv2 by Vaerys-Dawn.
the class BotStats method execute.
@Override
public String execute(String args, CommandObject command) {
List<Double> cpuUsage = TimerHandler.cpuUsage;
long freeMemory = Runtime.getRuntime().freeMemory();
long totalMemory = Runtime.getRuntime().totalMemory();
long usedMemory = totalMemory - freeMemory;
long userCount = command.client.get().getUsers().size();
double usage = cpuUsage.stream().mapToDouble(value -> value).sum() / cpuUsage.size();
// and make it look pretty
NumberFormat nf = NumberFormat.getInstance();
long ping = command.client.get().getShards().get(0).getResponseTime();
double mb = 1048576.0;
XEmbedBuilder builder = new XEmbedBuilder(command);
builder.withTitle(command.client.bot.username);
builder.withTimestamp(command.client.bot.get().getCreationDate());
builder.withFooterText("Creation Date");
StringHandler handler = new StringHandler();
handler.append("**Total Servers**: ").append(command.client.get().getGuilds().size());
handler.append(indent + "**Total Users**: " + userCount);
handler.append("\n**Total Active Threads**: ").append(Thread.activeCount());
handler.append("\n**CPU Usage**: ").append(nf.format(usage * 100)).append("%");
handler.append("\n**Memory Usage**: ");
nf.setMaximumFractionDigits(1);
handler.append(nf.format(totalMemory / mb)).append("MB total\t");
handler.append(nf.format(usedMemory / mb)).append("MB used\t");
handler.append(nf.format(freeMemory / mb)).append("MB free");
handler.append("\n**Ping**: ").append(nf.format(ping)).append("ms");
builder.withDesc(handler.toString());
builder.withThumbnail(command.client.bot.getAvatarURL());
builder.send(command.channel);
return null;
}
Aggregations