@@ -34,13 +34,15 @@ public class HelpAccountSubcommand extends SlashCommand.Subcommand {
3434 */
3535 public HelpAccountSubcommand () {
3636 setSubcommandData (new SubcommandData ("account" , "Shows an overview of your Help Account." )
37- .addOption (OptionType .USER , "user" , "The user to check." , false )
37+ .addOption (OptionType .USER , "user" , "If set, show the Help Account of the specified user instead." , false )
38+ .addOption (OptionType .BOOLEAN , "show-transactions" , "Should the recent transactions be shown?" , false )
3839 );
3940 }
4041
4142 @ Override
4243 public void execute (@ NotNull SlashCommandInteractionEvent event ) {
4344 User user = event .getOption ("user" , event ::getUser , OptionMapping ::getAsUser );
45+ boolean showTransactions = event .getOption ("show-transactions" , false , OptionMapping ::getAsBoolean );
4446 long totalThanks = DbActions .count (
4547 "SELECT COUNT(id) FROM help_channel_thanks WHERE helper_id = ?" ,
4648 s -> s .setLong (1 , user .getIdLong ())
@@ -51,28 +53,28 @@ public void execute(@NotNull SlashCommandInteractionEvent event) {
5153 );
5254 try {
5355 HelpAccount account = new HelpExperienceService (Bot .dataSource ).getOrCreateAccount (user .getIdLong ());
54- event .replyEmbeds (buildHelpAccountEmbed (account , user , event .getGuild (), totalThanks , weekThanks )).queue ();
56+ event .replyEmbeds (buildHelpAccountEmbed (account , user , event .getGuild (), totalThanks , weekThanks , showTransactions )).queue ();
5557 } catch (SQLException e ) {
5658 ExceptionLogger .capture (e , getClass ().getSimpleName ());
5759 Responses .error (event , e .getMessage ()).queue ();
5860 }
5961 }
6062
61- private MessageEmbed buildHelpAccountEmbed (HelpAccount account , User user , Guild guild , long totalThanks , long weekThanks ) {
62- return new EmbedBuilder ()
63+ private @ NotNull MessageEmbed buildHelpAccountEmbed (HelpAccount account , @ NotNull User user , Guild guild , long totalThanks , long weekThanks , boolean showTransactions ) {
64+ return new EmbedBuilder ()
6365 .setAuthor (user .getAsTag (), null , user .getEffectiveAvatarUrl ())
6466 .setTitle ("Help Account" )
6567 .setThumbnail (user .getEffectiveAvatarUrl ())
6668 .setDescription ("Here are some statistics about how you've helped others here." )
67- .addField ("Experience (BETA)" , String .format ("%s\n \n **Recent Transactions** \n ```diff \n %s``` " ,
68- formatExperience (guild , account ),
69- formatTransactionHistory (user .getIdLong ())), false )
69+ .addField ("Experience (BETA)" , String .format ("%s%s " ,
70+ formatExperience (guild , account ),
71+ showTransactions ? String . format ( " \n \n **Recent Transactions** \n ```diff \n %s```" , formatTransactionHistory (user .getIdLong ())) : "" ), false )
7072 .addField ("Total Times Thanked" , String .format ("**%s**" , totalThanks ), true )
7173 .addField ("Times Thanked This Week" , String .format ("**%s**" , weekThanks ), true )
7274 .build ();
7375 }
7476
75- private String formatTransactionHistory (long userId ) {
77+ private @ NotNull String formatTransactionHistory (long userId ) {
7678 StringBuilder sb = new StringBuilder ();
7779 try {
7880 HelpExperienceService service = new HelpExperienceService (Bot .dataSource );
0 commit comments