Search in sources :

Example 1 with ToggleStatsObject

use of com.github.vaerys.objects.ToggleStatsObject in project DiscordSailv2 by Vaerys-Dawn.

the class GetGlobalStats method execute.

@Override
public String execute(String args, CommandObject command) {
    ArrayList<ToggleStatsObject> toggleStats = new ArrayList<>();
    ArrayList<String> outToggles = new ArrayList<>();
    ArrayList<String> outModules = new ArrayList<>();
    // ArrayList<ChannelStatsObject> channelStats = new ArrayList<>();
    for (GuildToggle g : Globals.getGuildToggles()) {
        toggleStats.add(new ToggleStatsObject(g.name().toString(), g.isModule()));
    }
    // for (ChannelSetting c : Globals.getChannelSettings()) {
    // channelStats.add(new ChannelStatsObject(c.type(), c.isSetting()));
    // }
    long totalXpUsers = 0;
    long totalXP = 0;
    for (GuildObject g : Globals.getGuilds()) {
        CommandObject object = command.setGuild(g.get());
        for (ToggleStatsObject s : toggleStats) {
            for (GuildToggle t : object.guild.toggles) {
                if (t.name().toString().equalsIgnoreCase(s.getToggle())) {
                    if (t.isModule()) {
                        s.addOne();
                    } else if (t.enabled(object.guild.config) != t.getDefault()) {
                        s.addOne();
                    }
                }
            }
        }
        // }
        if (command.guild.config.modulePixels) {
            for (ProfileObject o : command.guild.users.getProfiles()) {
                if (o.getXP() != 0) {
                    totalXP += o.getXP();
                    totalXpUsers++;
                }
            }
        }
    }
    for (ToggleStatsObject t : toggleStats) {
        String formatted = t.getToggle() + ": " + t.getCount();
        if (t.isModule()) {
            outModules.add(formatted);
        } else {
            outToggles.add(formatted);
        }
    }
    StringBuilder output = new StringBuilder();
    output.append("**[GLOBAL STATS]**");
    output.append("\n\n**[TOGGLE STATS]**\n");
    output.append(Utility.listFormatter(outToggles, false));
    output.append("\n\n**[MODULE STATS]**\n");
    output.append(Utility.listFormatter(outModules, false));
    output.append("\n\n**[PIXEL STATS]**");
    output.append("\nAvg Pixels: " + totalXP / totalXpUsers);
    command.user.sendDm(output.toString());
    return "> Data sent to Your DMs";
// int totalGlobalUsers = 0;
// int totalAvg = 0;
// for (IGuild guild : command.client.getGuilds()) {
// StringBuilder builder = new StringBuilder();
// long totalUsers = 0;
// long totalMessage = 0;
// long totalMessageAvg = 0;
// long topGuild = 0;
// long bottomGuild = 0;
// String topUser = null;
// String bottomUser = null;
// GuildContentObject content = Globals.getGuildContent(guild.getLongID());
// for (UserTypeObject user : content.getGuildUsers().getProfiles()) {
// if (bottomGuild == 0) {
// bottomGuild = user.getXP();
// bottomUser = user.getID();
// } else if (bottomGuild > user.getXP()) {
// bottomGuild = user.getXP();
// bottomUser = user.getID();
// }
// if (topGuild == 0) {
// topGuild = user.getXP();
// topUser = user.getID();
// } else if (topGuild < user.getXP()) {
// topGuild = user.getXP();
// topUser = user.getID();
// }
// totalMessage += user.getXP();
// totalGlobalUsers++;
// totalUsers++;
// }
// builder.append("**Guild: " + guild.getNames() + "**");
// IUser topIUser = command.client.getUserByID(topUser);
// IUser bottomIUser = command.client.getUserByID(bottomUser);
// if (topIUser != null && bottomIUser != null) {
// builder.append("\nTop User = @" + command.client.getUserByID(topUser).getNames() + "#" + command.client.getUserByID(topUser).getDiscriminator());
// builder.append(" With Total Messages " + topGuild);
// builder.append("\nBottom User = @" + command.client.getUserByID(bottomUser).getNames() + "#" + command.client.getUserByID(bottomUser).getDiscriminator());
// builder.append(" With Total Messages " + bottomGuild);
// builder.append("\nGuild Avg = " + totalMessageAvg / totalUsers);
// builder.append("\nTotal Guild Messages = " + totalMessage);
// builder.append("\nTotal Users = " + totalUsers);
// Utility.sendDM(builder.toString(), command.authorSID);
// }
// try {
// Thread.sleep(2000);
// } catch (InterruptedException e) {
// Utility.sendStack(e);
// }
// }
// StringBuilder builder = new StringBuilder("**Global Stats**");
// builder.append("\nGlobal profiles = " + totalGlobalUsers);
// builder.append("\nGlobal Avg = " + totalAvg / totalGlobalUsers);
// Utility.sendDM(builder.toString(), command.authorSID);
// return null;
}
Also used : CommandObject(com.github.vaerys.commands.CommandObject) GuildObject(com.github.vaerys.masterobjects.GuildObject) GuildToggle(com.github.vaerys.templates.GuildToggle) ToggleStatsObject(com.github.vaerys.objects.ToggleStatsObject) ArrayList(java.util.ArrayList) ProfileObject(com.github.vaerys.objects.ProfileObject)

Aggregations

CommandObject (com.github.vaerys.commands.CommandObject)1 GuildObject (com.github.vaerys.masterobjects.GuildObject)1 ProfileObject (com.github.vaerys.objects.ProfileObject)1 ToggleStatsObject (com.github.vaerys.objects.ToggleStatsObject)1 GuildToggle (com.github.vaerys.templates.GuildToggle)1 ArrayList (java.util.ArrayList)1