mirror of
https://github.com/SimplexDevelopment/Obsidian.git
synced 2024-11-16 16:26:11 +00:00
Send it!
This commit is contained in:
parent
30f8c558d2
commit
99d55f36da
3
.gitignore
vendored
3
.gitignore
vendored
@ -21,3 +21,6 @@
|
|||||||
|
|
||||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
hs_err_pid*
|
hs_err_pid*
|
||||||
|
.gradle/*
|
||||||
|
build/*
|
||||||
|
.idea/*
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -11,10 +11,10 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation 'org.jetbrains:annotations:20.1.0'
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
|
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
|
||||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
|
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
|
||||||
compile 'com.discord4j:discord4j-core:3.1.3'
|
compile 'com.discord4j:discord4j-core:3.1.3'
|
||||||
compile 'org.slf4j:slf4j-api:1.7.25'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
package io.github.paldiu.obsidian;
|
package io.github.paldiu.obsidian;
|
||||||
|
|
||||||
import io.github.paldiu.obsidian.utils.Constants;
|
import io.github.paldiu.obsidian.utils.Bot;
|
||||||
|
|
||||||
public final class Obsidian {
|
public final class Obsidian {
|
||||||
// This class only initializes the bot.
|
private static Bot bot;
|
||||||
// Using utility classes to manage instances.
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Constants.getRegistry().verify();
|
bot = new Bot();
|
||||||
|
getBot().verify();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Bot getBot() {
|
||||||
|
return bot;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,12 +10,4 @@ public class Commands {
|
|||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private Command coloredRank(User user, Message message) {
|
|
||||||
return () -> {
|
|
||||||
message.getGuild().
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
package io.github.paldiu.obsidian.embed;
|
||||||
|
|
||||||
|
public class Embedder {
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package io.github.paldiu.obsidian.listener;
|
||||||
|
|
||||||
|
import discord4j.core.event.domain.Event;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public interface EventListener<T extends Event> {
|
||||||
|
Logger LOG = Logger.getLogger(EventListener.class.getSimpleName());
|
||||||
|
|
||||||
|
Class<T> getEventType();
|
||||||
|
|
||||||
|
Mono<Void> execute(T event);
|
||||||
|
|
||||||
|
default Mono<Void> handleError(Throwable error) {
|
||||||
|
LOG.severe("Unable to process " + getEventType().getSimpleName() + "\n" + error.getMessage());
|
||||||
|
return Mono.empty();
|
||||||
|
}
|
||||||
|
}
|
@ -27,7 +27,7 @@ public class PropertiesManager {
|
|||||||
properties.setProperty("author", "Predicate<? super T>#0001");
|
properties.setProperty("author", "Predicate<? super T>#0001");
|
||||||
properties.setProperty("version", "1.0.0");
|
properties.setProperty("version", "1.0.0");
|
||||||
properties.setProperty("encoding", "UTF_8");
|
properties.setProperty("encoding", "UTF_8");
|
||||||
properties.setProperty("token", "REPLACEME");
|
properties.setProperty("token", "BOT_TOKEN");
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ public class PropertiesManager {
|
|||||||
try (OutputStream stream = new FileOutputStream(child)) {
|
try (OutputStream stream = new FileOutputStream(child)) {
|
||||||
properties.store(stream, null);
|
properties.store(stream, null);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Constants.getLogger().error(e.getMessage());
|
Constants.getLogger().severe(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
17
src/main/java/io/github/paldiu/obsidian/ticketer/Ticket.java
Normal file
17
src/main/java/io/github/paldiu/obsidian/ticketer/Ticket.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package io.github.paldiu.obsidian.ticketer;
|
||||||
|
|
||||||
|
import discord4j.core.object.entity.User;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public interface Ticket {
|
||||||
|
User getUserCreated();
|
||||||
|
|
||||||
|
User getAssignedUser();
|
||||||
|
|
||||||
|
Supplier<String> getCommissionSpecifications();
|
||||||
|
|
||||||
|
Supplier<Integer> getCommissionPrice();
|
||||||
|
|
||||||
|
TicketStatus getTicketStatus();
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
package io.github.paldiu.obsidian.ticketer;
|
||||||
|
|
||||||
|
import discord4j.core.object.entity.User;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class TicketModule {
|
||||||
|
private volatile Ticket ticket;
|
||||||
|
|
||||||
|
public TicketModule(Ticket ticket) {
|
||||||
|
this.ticket = ticket;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TicketModule() {
|
||||||
|
ticket = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TicketModule createNewTicket(User userCreated, User assigned, Supplier<String> commissionSpecifications, Supplier<Integer> commissionPrice, TicketStatus type) {
|
||||||
|
ticket = new Ticket() {
|
||||||
|
@Override
|
||||||
|
public User getUserCreated() {
|
||||||
|
return assigned;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public User getAssignedUser() {
|
||||||
|
return userCreated;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Supplier<String> getCommissionSpecifications() {
|
||||||
|
return commissionSpecifications;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Supplier<Integer> getCommissionPrice() {
|
||||||
|
return commissionPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TicketStatus getTicketStatus() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ticket getTicket() {
|
||||||
|
return ticket;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package io.github.paldiu.obsidian.ticketer;
|
||||||
|
|
||||||
|
public enum TicketStatus {
|
||||||
|
OPEN("The ticket has been marked as open."),
|
||||||
|
PENDING("The ticket is now pending approval."),
|
||||||
|
IN_PROGRESS("The ticket is now in progress."),
|
||||||
|
COMPLETED("The ticket has been marked as completed."),
|
||||||
|
CLOSED("The ticket has been marked as closed.");
|
||||||
|
|
||||||
|
private final String message;
|
||||||
|
|
||||||
|
TicketStatus(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,6 @@ package io.github.paldiu.obsidian.utils;
|
|||||||
|
|
||||||
import discord4j.common.util.Snowflake;
|
import discord4j.common.util.Snowflake;
|
||||||
import discord4j.core.DiscordClient;
|
import discord4j.core.DiscordClient;
|
||||||
import discord4j.core.DiscordClientBuilder;
|
|
||||||
import discord4j.core.GatewayDiscordClient;
|
import discord4j.core.GatewayDiscordClient;
|
||||||
import discord4j.core.event.domain.lifecycle.ReadyEvent;
|
import discord4j.core.event.domain.lifecycle.ReadyEvent;
|
||||||
import discord4j.core.object.entity.User;
|
import discord4j.core.object.entity.User;
|
||||||
@ -11,12 +10,12 @@ import discord4j.discordjson.json.UserData;
|
|||||||
import discord4j.rest.response.ResponseFunction;
|
import discord4j.rest.response.ResponseFunction;
|
||||||
import io.github.paldiu.obsidian.props.PropertiesManager;
|
import io.github.paldiu.obsidian.props.PropertiesManager;
|
||||||
|
|
||||||
public final class Registry {
|
public final class Bot {
|
||||||
private final GatewayDiscordClient gateway;
|
private final GatewayDiscordClient gateway;
|
||||||
private final DiscordClient client;
|
private final DiscordClient client;
|
||||||
private final String token;
|
private final String token;
|
||||||
|
|
||||||
public Registry() {
|
public Bot() {
|
||||||
PropertiesManager.getInstance().load();
|
PropertiesManager.getInstance().load();
|
||||||
token = PropertiesManager.getInstance().getToken();
|
token = PropertiesManager.getInstance().getToken();
|
||||||
client = DiscordClient.builder(token)
|
client = DiscordClient.builder(token)
|
@ -1,17 +1,19 @@
|
|||||||
package io.github.paldiu.obsidian.utils;
|
package io.github.paldiu.obsidian.utils;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import java.util.function.Consumer;
|
||||||
import org.slf4j.LoggerFactory;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
// Utility Class
|
||||||
public final class Constants {
|
public final class Constants {
|
||||||
private static final Logger logger = LoggerFactory.getLogger("obsidian");
|
private static final Logger logger = Logger.getLogger("obsidian");
|
||||||
private static final Registry registry = new Registry();
|
|
||||||
|
|
||||||
public static Logger getLogger() {
|
public static Logger getLogger() {
|
||||||
return logger;
|
return logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Registry getRegistry() {
|
public static <T> void forEach(T[] array, Consumer<T> action) {
|
||||||
return registry;
|
for (T obj : array) {
|
||||||
|
action.accept(obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user