Compare commits
3 Commits
5d34048ae6
...
d95338d833
Author | SHA1 | Date | |
---|---|---|---|
d95338d833 | |||
df1219953e | |||
5d576b08eb |
13
.drone.yml
Normal file
13
.drone.yml
Normal 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
10
pom.xml
@ -20,6 +20,16 @@
|
|||||||
<artifactId>JDA</artifactId>
|
<artifactId>JDA</artifactId>
|
||||||
<version>5.0.0-alpha.18</version>
|
<version>5.0.0-alpha.18</version>
|
||||||
</dependency>
|
</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>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -2,20 +2,23 @@ package wtf.beatrice.hidekobot;
|
|||||||
|
|
||||||
import net.dv8tion.jda.api.JDA;
|
import net.dv8tion.jda.api.JDA;
|
||||||
import net.dv8tion.jda.api.JDABuilder;
|
import net.dv8tion.jda.api.JDABuilder;
|
||||||
|
import wtf.beatrice.hidekobot.utils.Logger;
|
||||||
|
|
||||||
import javax.security.auth.login.LoginException;
|
import javax.security.auth.login.LoginException;
|
||||||
|
|
||||||
public class HidekoBot
|
public class HidekoBot
|
||||||
{
|
{
|
||||||
|
private static Logger logger = new Logger(HidekoBot.class);
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
JDA jda = JDABuilder.createDefault("token").build();
|
JDA jda = JDABuilder.createDefault("").build();
|
||||||
} catch (LoginException e)
|
} catch (LoginException e)
|
||||||
{
|
{
|
||||||
throw new RuntimeException(e);
|
logger.log(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
31
src/main/java/wtf/beatrice/hidekobot/utils/Logger.java
Normal file
31
src/main/java/wtf/beatrice/hidekobot/utils/Logger.java
Normal 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));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user