Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ public static void initialize() throws LoginException {
new DiscussionMuteCommand(),
new NbsCommand(),
new DailySessionsCommand(),
new EightBallCommand()
new EightBallCommand(),
new JoinsCommand()
);

JDABuilder builder = JDABuilder.createDefault(config.getToken())
Expand Down Expand Up @@ -144,4 +145,4 @@ public static Config getConfig() {
public static TaskRegistry getScheduler() {
return loop;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.diamondfire.helpbot.bot.command.impl.stats;

import com.diamondfire.helpbot.bot.command.argument.ArgumentSet;
import com.diamondfire.helpbot.bot.command.help.*;
import com.diamondfire.helpbot.bot.command.impl.Command;
import com.diamondfire.helpbot.bot.command.permissions.Permission;
import com.diamondfire.helpbot.bot.events.CommandEvent;
import com.diamondfire.helpbot.sys.database.impl.DatabaseQuery;
import com.diamondfire.helpbot.sys.database.impl.queries.BasicQuery;
import com.diamondfire.helpbot.util.FormatUtil;
import net.dv8tion.jda.api.EmbedBuilder;

public class JoinsCommand extends Command {

@Override
public String getName() { return "joins"; }

@Override
public HelpContext getHelpContext() {
return new HelpContext()
.description("Shows the total amount of unique players that have joined DiamondFire before.")
.category(CommandCategory.GENERAL_STATS);
}

@Override
public ArgumentSet compileArguments() { return new ArgumentSet(); }

@Override
public Permission getPermission() { return Permission.USER; }

@Override
public void run(CommandEvent event) {
EmbedBuilder builder = new EmbedBuilder();

builder.setTitle("Total Joins");

// gets the total amount of players that have joined before
new DatabaseQuery()
.query(new BasicQuery("SELECT COUNT(*) AS count FROM players"))
.compile()
.run((result) -> {
String count = FormatUtil.formatNumber(result.getResult().getInt("count"));
builder.setDescription(String.format("A total of %s players have joined DiamondFire before!", count));
});

event.getChannel().sendMessage(builder.build()).queue();
}
}