forked from Fascinated/Bat
add scoresaber feed command and websocket impl
This commit is contained in:
@ -19,6 +19,7 @@ public class NumberUtils {
|
||||
public static String formatNumberCommas(double number) {
|
||||
NumberFormat format = NumberFormat.getNumberInstance();
|
||||
format.setGroupingUsed(true);
|
||||
format.setMaximumFractionDigits(2);
|
||||
return format.format(number);
|
||||
}
|
||||
}
|
||||
|
23
src/main/java/cc/fascinated/bat/common/ScoreSaberUtils.java
Normal file
23
src/main/java/cc/fascinated/bat/common/ScoreSaberUtils.java
Normal file
@ -0,0 +1,23 @@
|
||||
package cc.fascinated.bat.common;
|
||||
|
||||
/**
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
public class ScoreSaberUtils {
|
||||
/**
|
||||
* Gets the formatted difficulty of a song.
|
||||
*
|
||||
* @param difficulty the difficulty to format
|
||||
* @return the formatted difficulty
|
||||
*/
|
||||
public static String getFormattedDifficulty(int difficulty) {
|
||||
return switch (difficulty) {
|
||||
case 1 -> "Easy";
|
||||
case 3 -> "Normal";
|
||||
case 5 -> "Hard";
|
||||
case 7 -> "Expert";
|
||||
case 8 -> "Expert+";
|
||||
default -> "Unknown";
|
||||
};
|
||||
}
|
||||
}
|
31
src/main/java/cc/fascinated/bat/common/TextChannelUtils.java
Normal file
31
src/main/java/cc/fascinated/bat/common/TextChannelUtils.java
Normal file
@ -0,0 +1,31 @@
|
||||
package cc.fascinated.bat.common;
|
||||
|
||||
import cc.fascinated.bat.service.DiscordService;
|
||||
|
||||
/**
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
public class TextChannelUtils {
|
||||
/**
|
||||
* Checks if a channel is valid
|
||||
*
|
||||
* @param id the id of the channel
|
||||
* @return if the channel is valid
|
||||
*/
|
||||
public static boolean isValidChannel(String id) {
|
||||
if (id == null) {
|
||||
return false;
|
||||
}
|
||||
return DiscordService.JDA.getTextChannelById(id) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mention of a channel
|
||||
*
|
||||
* @param id the id of the channel
|
||||
* @return the mention of the channel
|
||||
*/
|
||||
public static String getChannelMention(String id) {
|
||||
return "<#" + id + ">";
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user