package com.tisawesomeness.minecord.command.admin;

import com.tisawesomeness.minecord.Bot;
import com.tisawesomeness.minecord.command.Command;
import com.tisawesomeness.minecord.command.Module;
import com.tisawesomeness.minecord.command.Registry;
import com.tisawesomeness.minecord.util.DateUtils;
import com.tisawesomeness.minecord.util.MessageUtils;

import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;

public class UsageCommand extends Command {
	
	public CommandInfo getInfo() {
		return new CommandInfo(
			"usage",
			"Shows how often commands are used.",
			"",
			new String[0],
			0,
			true,
			true,
			false
		);
	}
	
	public Result run(String[] args, MessageReceivedEvent e) {
		
		//Iterate over commands
		String m = "";
		for (Module mod : Registry.modules) {
			for (Command c : mod.getCommands()) {
				CommandInfo ci = c.getInfo();
				if ("".equals(ci.name)) {continue;}
				
				//Build message
				m += "`" + MessageUtils.getPrefix(e) + ci.name + "` **-** " + c.uses + "\n";
			}
		}
		m = m.substring(0, m.length() - 1);

		String title = "Command usage for " + DateUtils.getUptime();
		MessageEmbed me = MessageUtils.embedMessage(title, null, m, Bot.color);
		return new Result(Outcome.SUCCESS, me);
	}
	
}

@@ -45,16 +45,78 @@
 admin;%0A%0A
+import java.util.Arrays;%0Aimport java.util.stream.Collectors;%0A%0A
 import c
@@ -440,29 +440,20 @@
 api.
-entities.MessageEmbed
+EmbedBuilder
 ;%0Aim
@@ -679,28 +679,21 @@
 %0A%09%09%09
-%22%22
+null
 ,%0A%09%09%09n
-ew String%5B0%5D
+ull
 ,%0A%09%09
@@ -799,50 +799,198 @@
 %7B%0A%09%09
-%0A%09%09//Iterate over commands%0A%09%09String m = %22%22
+String prefix = MessageUtils.getPrefix(e);%0A%0A%09%09// Build usage message%0A%09%09EmbedBuilder eb = new EmbedBuilder()%0A%09%09%09.setTitle(%22Command usage for %22 + DateUtils.getUptime())%0A%09%09%09.setColor(Bot.color)
 ;%0A%09%09
@@ -1002,18 +1002,16 @@
 Module m
-od
  : Regis
@@ -1032,410 +1032,303 @@
 %0A%09%09%09
-for (Command c : mod.getCommands()) %7B%0A%09%09%09%09CommandInfo ci = c.getInfo();%0A%09%09%09%09if (%22%22.equals(ci.name)) %7Bcontinue;%7D%0A%09%09%09%09%0A%09%09%09%09//Build message%0A%09%09%09%09m += %22%60%22 + MessageUtils.getPrefix(e) + ci.name + %22%60 **-** %22 + c.uses + %22%5Cn%22;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09m = m.substring(0, m.length() - 1
+String field = Arrays.asList(m.getCommands()).stream()%0A%09%09%09%09.filter(c -%3E !c.getInfo().name.equals(%22%22))%0A%09%09%09%09.map(c -%3E String.format(%22%60%25s%25s%60 **-** %25d%22, prefix, c.getInfo().name, c.uses))%0A%09%09%09%09.collect(Collectors.joining(%22%5Cn%22)
 );%0A
-%0A
 %09%09
-String title = %22Command usage for %22 + DateUtils.getUptime();%0A%09%09MessageEmbed me = MessageUtils.embedMessage(title, null, m, Bot.color);
+%09eb.addField(String.format(%22**%25s**%22, m.getName()), field, true);%0A%09%09%7D%0A
 %0A%09%09r
@@ -1361,18 +1361,50 @@
 UCCESS, 
-me
+MessageUtils.addFooter(eb).build()
 );%0A%09%7D%0A%09%0A

Make &usage cleaner