feat: add JdaAutoConfiguration.kt
All checks were successful
Release / release (push) Successful in 2m7s
All checks were successful
Release / release (push) Successful in 2m7s
This commit is contained in:
8
pom.xml
8
pom.xml
@@ -38,6 +38,11 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
<artifactId>kotlin-reflect</artifactId>
|
<artifactId>kotlin-reflect</artifactId>
|
||||||
@@ -66,6 +71,9 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<skip>true</skip>
|
||||||
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package fr.lucasdupont.configuration
|
||||||
|
|
||||||
|
import fr.lucasdupont.service.JdaService
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfiguration
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties
|
||||||
|
import org.springframework.context.ApplicationContext
|
||||||
|
import org.springframework.context.ApplicationEventPublisher
|
||||||
|
import org.springframework.context.annotation.Bean
|
||||||
|
import org.springframework.context.annotation.ComponentScan
|
||||||
|
|
||||||
|
@AutoConfiguration
|
||||||
|
@EnableConfigurationProperties(JdaConfiguration::class)
|
||||||
|
@ConditionalOnProperty(prefix = "jda", name = ["token"])
|
||||||
|
@ComponentScan(basePackages = ["fr.lucasdupont"])
|
||||||
|
class JdaAutoConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
fun jdaService(
|
||||||
|
applicationContext: ApplicationContext,
|
||||||
|
jdaConfiguration: JdaConfiguration,
|
||||||
|
publisher: ApplicationEventPublisher
|
||||||
|
): JdaService {
|
||||||
|
return JdaService(applicationContext, jdaConfiguration, publisher)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -11,15 +11,11 @@ import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEve
|
|||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter
|
import net.dv8tion.jda.api.hooks.ListenerAdapter
|
||||||
import net.dv8tion.jda.api.requests.GatewayIntent
|
import net.dv8tion.jda.api.requests.GatewayIntent
|
||||||
import net.dv8tion.jda.api.utils.cache.CacheFlag
|
import net.dv8tion.jda.api.utils.cache.CacheFlag
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties
|
|
||||||
import org.springframework.context.ApplicationContext
|
import org.springframework.context.ApplicationContext
|
||||||
import org.springframework.context.ApplicationEventPublisher
|
import org.springframework.context.ApplicationEventPublisher
|
||||||
import org.springframework.context.PayloadApplicationEvent
|
import org.springframework.context.PayloadApplicationEvent
|
||||||
import org.springframework.context.event.EventListener
|
import org.springframework.context.event.EventListener
|
||||||
import org.springframework.stereotype.Service
|
|
||||||
|
|
||||||
@Service
|
|
||||||
@EnableConfigurationProperties(JdaConfiguration::class)
|
|
||||||
class JdaService(
|
class JdaService(
|
||||||
applicationContext: ApplicationContext,
|
applicationContext: ApplicationContext,
|
||||||
jdaConfiguration: JdaConfiguration,
|
jdaConfiguration: JdaConfiguration,
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fr.lucasdupont.configuration.JdaAutoConfiguration
|
||||||
|
|
||||||
Reference in New Issue
Block a user