Compare commits

...

3 Commits

Author SHA1 Message Date
d95338d833 Add Drone CI support 2022-08-25 22:14:48 +02:00
df1219953e Fix log4j dependencies 2022-08-25 22:13:53 +02:00
5d576b08eb Add Logger class 2022-08-25 22:13:39 +02:00
4 changed files with 59 additions and 2 deletions

13
.drone.yml Normal file
View File

@ -0,0 +1,13 @@
kind: pipeline
name: default
trigger:
branch:
- main
steps:
- name: build
image: maven:3-eclipse-temurin-16
commands:
- mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
- mvn test -B

10
pom.xml
View File

@ -20,6 +20,16 @@
<artifactId>JDA</artifactId>
<version>5.0.0-alpha.18</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
<build>

View File

@ -2,20 +2,23 @@ package wtf.beatrice.hidekobot;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import wtf.beatrice.hidekobot.utils.Logger;
import javax.security.auth.login.LoginException;
public class HidekoBot
{
private static Logger logger = new Logger(HidekoBot.class);
public static void main(String[] args)
{
try
{
JDA jda = JDABuilder.createDefault("token").build();
JDA jda = JDABuilder.createDefault("").build();
} catch (LoginException e)
{
throw new RuntimeException(e);
logger.log(e.getMessage());
}
}
}

View File

@ -0,0 +1,31 @@
package wtf.beatrice.hidekobot.utils;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class Logger
{
// objects that we need to have for a properly formatted message
private String className;
private final String format = "[%date%] [%class%] %message%";
private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("YYYY-MM-dd");
// when initializing a new logger, save variables in that instance
public Logger(Class logClass)
{
className = logClass.getSimpleName();
}
// log a message to console, with our chosen format
public void log(String message)
{
LocalDateTime now = LocalDateTime.now();
String currentTime = formatter.format(now);
System.out.println(format
.replace("%date%", currentTime)
.replace("%class%", className)
.replace("%message%", message));
}
}