From cdfa07b31f6777f3eeaa37543160da8817999b71 Mon Sep 17 00:00:00 2001
From: Stiliyan Nanovski
Date: Tue, 29 Aug 2023 17:20:20 +0300
Subject: [PATCH] Fix final bugs and prepare for v0.0.1.
---
build.gradle | 13 +-----
.../mad4j/Mad4jAutoConfiguration.java | 28 ------------
src/main/java/stelitop/mad4j/Mad4jConfig.java | 7 +++
.../stelitop/mad4j/SlashCommandRegistrar.java | 1 +
.../CommandOptionAutocompleteListener.java | 1 +
.../listeners/ComponentEventListener.java | 1 +
.../Mad4jListenersAutoConfiguration.java | 43 -------------------
.../mad4j/listeners/SlashCommandListener.java | 1 +
8 files changed, 12 insertions(+), 83 deletions(-)
delete mode 100644 src/main/java/stelitop/mad4j/Mad4jAutoConfiguration.java
create mode 100644 src/main/java/stelitop/mad4j/Mad4jConfig.java
delete mode 100644 src/main/java/stelitop/mad4j/listeners/Mad4jListenersAutoConfiguration.java
diff --git a/build.gradle b/build.gradle
index 2908913..1c941a7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -6,7 +6,7 @@ plugins {
}
group = 'net.stelitop'
-version = '0.0.1-alpha-4'
+version = '0.0.1'
java {
sourceCompatibility = '17'
@@ -54,17 +54,6 @@ publishing {
}
}
-//uploadArchives {
-// repositories {
-// mavenDeployer {
-// repository(url: "file:///tmp/myRepo/")
-// pom.groupId = 'stelitop'
-// pom.version = '0.0.1-SNAPSHOT'
-// pom.artifactId = 'mad4j'
-// }
-// }
-//}
-
tasks.named('test') {
useJUnitPlatform()
}
diff --git a/src/main/java/stelitop/mad4j/Mad4jAutoConfiguration.java b/src/main/java/stelitop/mad4j/Mad4jAutoConfiguration.java
deleted file mode 100644
index d1ed226..0000000
--- a/src/main/java/stelitop/mad4j/Mad4jAutoConfiguration.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package stelitop.mad4j;
-
-import discord4j.core.GatewayDiscordClient;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.env.Environment;
-import stelitop.mad4j.listeners.CommandOptionAutocompleteListener;
-
-@Configuration
-public class Mad4jAutoConfiguration {
-
- @Bean
- public SlashCommandRegistrar slashCommandRegistrar(
- GatewayDiscordClient gatewayDiscordClient,
- CommandOptionAutocompleteListener commandOptionAutocompleteListener,
- ApplicationContext applicationContext,
- Environment environment
- ) {
- return new SlashCommandRegistrar(
- gatewayDiscordClient,
- commandOptionAutocompleteListener,
- applicationContext,
- environment
- );
- }
-}
diff --git a/src/main/java/stelitop/mad4j/Mad4jConfig.java b/src/main/java/stelitop/mad4j/Mad4jConfig.java
new file mode 100644
index 0000000..a9abd7b
--- /dev/null
+++ b/src/main/java/stelitop/mad4j/Mad4jConfig.java
@@ -0,0 +1,7 @@
+package stelitop.mad4j;
+
+import org.springframework.context.annotation.ComponentScan;
+
+@ComponentScan("stelitop.mad4j")
+public class Mad4jConfig {
+}
diff --git a/src/main/java/stelitop/mad4j/SlashCommandRegistrar.java b/src/main/java/stelitop/mad4j/SlashCommandRegistrar.java
index c9d586d..f992c0a 100644
--- a/src/main/java/stelitop/mad4j/SlashCommandRegistrar.java
+++ b/src/main/java/stelitop/mad4j/SlashCommandRegistrar.java
@@ -42,6 +42,7 @@
* to false in the application.properties file. This can be used because sometimes discord will
* "outdate" the commands and require you to wait.
*/
+@Component
public class SlashCommandRegistrar implements ApplicationRunner {
private final Logger LOGGER = LoggerFactory.getLogger(this.getClass());
diff --git a/src/main/java/stelitop/mad4j/listeners/CommandOptionAutocompleteListener.java b/src/main/java/stelitop/mad4j/listeners/CommandOptionAutocompleteListener.java
index 753cd0b..494f656 100644
--- a/src/main/java/stelitop/mad4j/listeners/CommandOptionAutocompleteListener.java
+++ b/src/main/java/stelitop/mad4j/listeners/CommandOptionAutocompleteListener.java
@@ -22,6 +22,7 @@
import java.util.Map;
import java.util.stream.Collectors;
+@Component
public class CommandOptionAutocompleteListener implements ApplicationRunner {
private final Logger LOGGER = LoggerFactory.getLogger(this.getClass());
diff --git a/src/main/java/stelitop/mad4j/listeners/ComponentEventListener.java b/src/main/java/stelitop/mad4j/listeners/ComponentEventListener.java
index ad0522f..04e4747 100644
--- a/src/main/java/stelitop/mad4j/listeners/ComponentEventListener.java
+++ b/src/main/java/stelitop/mad4j/listeners/ComponentEventListener.java
@@ -31,6 +31,7 @@
import java.util.*;
import java.util.stream.Collectors;
+@Component
public class ComponentEventListener implements ApplicationRunner {
private final Logger LOGGER = LoggerFactory.getLogger(this.getClass());
diff --git a/src/main/java/stelitop/mad4j/listeners/Mad4jListenersAutoConfiguration.java b/src/main/java/stelitop/mad4j/listeners/Mad4jListenersAutoConfiguration.java
deleted file mode 100644
index df5c850..0000000
--- a/src/main/java/stelitop/mad4j/listeners/Mad4jListenersAutoConfiguration.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package stelitop.mad4j.listeners;
-
-import discord4j.core.GatewayDiscordClient;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import stelitop.mad4j.autocomplete.AutocompletionExecutor;
-import stelitop.mad4j.requirements.CommandRequirementExecutor;
-
-import java.util.List;
-
-@Configuration
-public class Mad4jListenersAutoConfiguration {
-
- @Bean
- public SlashCommandListener slashCommandListener(
- ApplicationContext applicationContext,
- GatewayDiscordClient client,
- List possibleRequirements
- ) {
- return new SlashCommandListener(
- applicationContext,
- client,
- possibleRequirements
- );
- }
-
- @Bean
- public CommandOptionAutocompleteListener commandOptionAutocompleteListener(
- GatewayDiscordClient client,
- List autocompletionExecutors
- ) {
- return new CommandOptionAutocompleteListener(client, autocompletionExecutors);
- }
-
- @Bean
- public ComponentEventListener componentEventListener(
- GatewayDiscordClient client,
- ApplicationContext applicationContext
- ) {
- return new ComponentEventListener(client, applicationContext);
- }
-}
diff --git a/src/main/java/stelitop/mad4j/listeners/SlashCommandListener.java b/src/main/java/stelitop/mad4j/listeners/SlashCommandListener.java
index 42dbf3e..a8fd553 100644
--- a/src/main/java/stelitop/mad4j/listeners/SlashCommandListener.java
+++ b/src/main/java/stelitop/mad4j/listeners/SlashCommandListener.java
@@ -44,6 +44,7 @@
* These requirements are first checked against and if any of them are unfulfilled, the execution
* is cancelled and an error message is returned instead.
*/
+@Component
public class SlashCommandListener implements ApplicationRunner {
private final Logger LOGGER = LoggerFactory.getLogger(this.getClass());