Search in sources :

Example 6 with Command

use of de.tectoast.emolga.commands.Command in project Emolga by TecToast.

the class StatisticsCommand method process.

@Override
public void process(GuildCommandEvent e) throws Exception {
    ResultSet set = Database.select("SELECT * FROM `statistics` ORDER BY `count` DESC");
    String analysis = "";
    ArrayList<String> otherCmds = new ArrayList<>();
    while (set.next()) {
        int count = set.getInt("count");
        String name = set.getString("name");
        if (name.equals("analysis"))
            analysis = "Analysierte Replays: " + count;
        else {
            Command c = byName(name.substring(4));
            if (c == null)
                continue;
            logger.info("name = " + name);
            if (c.checkBot(e.getJDA(), e.getGuild().getIdLong()))
                otherCmds.add(c.getPrefix() + c.getName() + ": " + count);
        }
    }
    e.reply(new EmbedBuilder().setColor(Color.CYAN).setTitle("Anzahl der Nutzung").setDescription(analysis + "\n" + String.join("\n", otherCmds)).build());
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) Command(de.tectoast.emolga.commands.Command) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList)

Aggregations

Command (de.tectoast.emolga.commands.Command)6 CommandCategory (de.tectoast.emolga.commands.CommandCategory)3 GuildCommandEvent (de.tectoast.emolga.commands.GuildCommandEvent)3 ArrayList (java.util.ArrayList)3 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)3 Guild (net.dv8tion.jda.api.entities.Guild)2 Member (net.dv8tion.jda.api.entities.Member)2 TextChannel (net.dv8tion.jda.api.entities.TextChannel)2 HttpHandler (de.tectoast.emolga.jetty.HttpHandler)1 MYSERVER (de.tectoast.emolga.utils.Constants.MYSERVER)1 Giveaway (de.tectoast.emolga.utils.Giveaway)1 MessageWaiter (de.tectoast.emolga.utils.MessageWaiter)1 Draft (de.tectoast.emolga.utils.draft.Draft)1 Tierlist (de.tectoast.emolga.utils.draft.Tierlist)1 DBManagers (de.tectoast.emolga.utils.sql.DBManagers)1 ReactionManager (de.tectoast.toastilities.managers.ReactionManager)1 DatatypeConverter (jakarta.xml.bind.DatatypeConverter)1 java.awt (java.awt)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1