forked from Fascinated/Bat
cleanup and acc country flag to ss me and user command
This commit is contained in:
parent
50b921c66d
commit
406d6b7164
@ -44,7 +44,7 @@ public class HelpCommand extends BatCommand implements EventListener {
|
|||||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
||||||
String categories = "";
|
String categories = "";
|
||||||
for (Category category : Category.values()) {
|
for (Category category : Category.values()) {
|
||||||
long commandCount = commandService.getCommands().values().stream().filter(command -> command.getCategory() == category).count();
|
long commandCount = commandService.getCommandsByCategory(category).size();
|
||||||
categories += "**%s** - %s Commands\n".formatted(category.getName(), commandCount);
|
categories += "**%s** - %s Commands\n".formatted(category.getName(), commandCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,9 +76,7 @@ public class HelpCommand extends BatCommand implements EventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String commands = "";
|
String commands = "";
|
||||||
List<BatCommand> categoryCommands = commandService.getCommands().values().stream()
|
List<BatCommand> categoryCommands = commandService.getCommandsByCategory(category);
|
||||||
.filter(command -> command.getCategory() == category)
|
|
||||||
.toList();
|
|
||||||
if (categoryCommands.isEmpty()) {
|
if (categoryCommands.isEmpty()) {
|
||||||
commands = "No commands available in this category.";
|
commands = "No commands available in this category.";
|
||||||
} else {
|
} else {
|
||||||
@ -105,7 +103,7 @@ public class HelpCommand extends BatCommand implements EventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
event.editMessageEmbeds(EmbedUtils.genericEmbed()
|
event.editMessageEmbeds(EmbedUtils.genericEmbed()
|
||||||
.setDescription("The available commands in the **%s** category: \n\n%s".formatted(category.getName(), commands))
|
.setDescription("There is %S commands in the **%s** category: \n\n%s".formatted(categoryCommands.size(), category.getName(), commands))
|
||||||
.build()).queue();
|
.build()).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ public class ScoreSaberCommand extends BatCommand {
|
|||||||
.addField("PP", NumberUtils.formatNumberCommas(account.getPp()), true)
|
.addField("PP", NumberUtils.formatNumberCommas(account.getPp()), true)
|
||||||
.addField("Joined", "<t:%s>".formatted(DateUtils.getDateFromString(account.getFirstSeen()).toInstant().toEpochMilli() / 1000), true)
|
.addField("Joined", "<t:%s>".formatted(DateUtils.getDateFromString(account.getFirstSeen()).toInstant().toEpochMilli() / 1000), true)
|
||||||
.setTimestamp(LocalDateTime.now())
|
.setTimestamp(LocalDateTime.now())
|
||||||
.setFooter(fetchTime > 3 ? "Fetched in %sms".formatted(fetchTime) : "Cached", null)
|
.setFooter(fetchTime > 3 ? "Fetched in %sms".formatted(fetchTime) : "Cached", "https://flagcdn.com/h120/%s.png".formatted(account.getCountry().toLowerCase()))
|
||||||
.setColor(Colors.DEFAULT)
|
.setColor(Colors.DEFAULT)
|
||||||
.build()).queue();
|
.build()).queue();
|
||||||
} catch (RateLimitException ex) {
|
} catch (RateLimitException ex) {
|
||||||
|
@ -3,6 +3,7 @@ package cc.fascinated.bat.service;
|
|||||||
import cc.fascinated.bat.command.BatCommand;
|
import cc.fascinated.bat.command.BatCommand;
|
||||||
import cc.fascinated.bat.command.BatCommandExecutor;
|
import cc.fascinated.bat.command.BatCommandExecutor;
|
||||||
import cc.fascinated.bat.command.BatSubCommand;
|
import cc.fascinated.bat.command.BatSubCommand;
|
||||||
|
import cc.fascinated.bat.command.Category;
|
||||||
import cc.fascinated.bat.common.EmbedUtils;
|
import cc.fascinated.bat.common.EmbedUtils;
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
import cc.fascinated.bat.model.BatGuild;
|
||||||
import cc.fascinated.bat.model.BatUser;
|
import cc.fascinated.bat.model.BatUser;
|
||||||
@ -98,6 +99,16 @@ public class CommandService extends ListenerAdapter {
|
|||||||
log.info("Registered all slash commands in {}ms", System.currentTimeMillis() - before);
|
log.info("Registered all slash commands in {}ms", System.currentTimeMillis() - before);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets commands that are in a specific category
|
||||||
|
*
|
||||||
|
* @param category The category
|
||||||
|
* @return The commands
|
||||||
|
*/
|
||||||
|
public List<BatCommand> getCommandsByCategory(Category category) {
|
||||||
|
return commands.values().stream().filter(command -> command.getCategory() == category).toList();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSlashCommandInteraction(@NotNull SlashCommandInteractionEvent event) {
|
public void onSlashCommandInteraction(@NotNull SlashCommandInteractionEvent event) {
|
||||||
Guild discordGuild = event.getGuild();
|
Guild discordGuild = event.getGuild();
|
||||||
|
Loading…
Reference in New Issue
Block a user