Retroactively add the class for the last commit 😳

This commit is contained in:
Anya 2022-05-21 22:41:57 -07:00
parent dfdd032a33
commit 9183d350df

View file

@ -0,0 +1,48 @@
package moe.oko.Kiafumi.util;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
/**
* Logging Class
* Provides static logging & extensible template messages.
* @author oko
*/
public class LoggingManager {
private static final Logger logger = LoggerFactory.getLogger("Kiafumi");
// Static logging reference
public static void debug(String str) { logger.debug(str); }
public static void info(String str) { logger.info(str); }
public static void warn(String str) { logger.warn(str); }
public static void error(String str) { logger.error(str); }
/**
* Used for logging commands with ease to console via a static method.
* @param event - the event ran
* @param msg - Any message to append with this.
*/
public static void slashLog(SlashCommandInteractionEvent event, @Nullable String msg) {
var user = event.getUser();
info("""
User [%s:%s] ran command: "%s" %s"""
.formatted(user.getName(), user.getId(), event.getName(), msg == null ? "" : msg));
}
public static void slashLog(SlashCommandInteractionEvent event) {
var user = event.getUser();
info("""
User [%s:%s] ran command: "%s"."""
.formatted(user.getName(), user.getId(), event.getName()));
}
public static void slashResponse(SlashCommandInteractionEvent event, String msg) {
var user = event.getUser();
info("""
User [%s:%s] was provided response: "%s\"""".formatted(user.getName(), user.getId(), msg));
}
}