Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a44d987042 | ||
|
|
67e4f971bc | ||
|
|
29a419a560 | ||
|
|
eddd857a20 | ||
|
|
7c74bd153e | ||
| 0ce59fead3 | |||
| 74263537d5 | |||
|
|
78189e5c75 | ||
|
|
e7fdd19928 | ||
|
|
be19485a25 | ||
|
|
4cc23b2749 | ||
|
|
147abd879d | ||
|
|
a7d3fb56e9 |
42
CHANGELOG.md
42
CHANGELOG.md
@@ -1,3 +1,45 @@
|
|||||||
|
## [1.3.1](https://git.tools.ldpt.fr/lucasdpt/spring-jda-starter/compare/1.3.0...1.3.1) (2025-12-17)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* CommandMapper ([67e4f97](https://git.tools.ldpt.fr/lucasdpt/spring-jda-starter/commit/67e4f971bc3e023cb5506ec05eef68b005145b92))
|
||||||
|
|
||||||
|
# [1.3.0](https://git.tools.ldpt.fr/lucasdpt/spring-jda-starter/compare/1.2.0...1.3.0) (2025-12-17)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add guild Id ([eddd857](https://git.tools.ldpt.fr/lucasdpt/spring-jda-starter/commit/eddd857a205a2f17e7581bd6a278dc354191777b))
|
||||||
|
|
||||||
|
# [1.2.0](https://git.tools.ldpt.fr/lucasdpt/spring-jda-starter/compare/1.1.0...1.2.0) (2025-12-16)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* bump ([0ce59fe](https://git.tools.ldpt.fr/lucasdpt/spring-jda-starter/commit/0ce59fead3fe53d13efee8922cf726cfc4bed853))
|
||||||
|
|
||||||
|
# [1.1.0](https://git.tools.ldpt.fr/lucasdpt/spring-jda-starter/compare/1.0.2...1.1.0) (2025-12-15)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add JdaAutoConfiguration.kt ([e7fdd19](https://git.tools.ldpt.fr/lucasdpt/spring-jda-starter/commit/e7fdd19928dbe20f0e71203cf4074c3ca5a9e667))
|
||||||
|
|
||||||
|
## [1.0.2](https://git.tools.ldpt.fr/lucasdpt/spring-jda-starter/compare/1.0.1...1.0.2) (2025-11-02)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* fix pom ([4cc23b2](https://git.tools.ldpt.fr/lucasdpt/spring-jda-starter/commit/4cc23b27499c443ae4487489c98d78d87c9e4884))
|
||||||
|
|
||||||
|
## [1.0.1](https://git.tools.ldpt.fr/lucasdpt/spring-jda-starter/compare/1.0.0...1.0.1) (2025-11-02)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* fix pom ([a7d3fb5](https://git.tools.ldpt.fr/lucasdpt/spring-jda-starter/commit/a7d3fb56e9b519ff7bbcad098b701f61fa5666c8))
|
||||||
|
|
||||||
# 1.0.0 (2025-11-02)
|
# 1.0.0 (2025-11-02)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
43
pom.xml
43
pom.xml
@@ -2,19 +2,14 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
|
||||||
<version>3.5.7</version>
|
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
|
||||||
</parent>
|
|
||||||
<groupId>fr.lucasdupont</groupId>
|
<groupId>fr.lucasdupont</groupId>
|
||||||
<artifactId>spring-jda-starter</artifactId>
|
<artifactId>spring-jda-starter</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.3.1</version>
|
||||||
<name>spring-jda-starter</name>
|
|
||||||
<description>Starter for JDA project</description>
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>21</java.version>
|
<java.version>21</java.version>
|
||||||
|
<spring.boot.version>4.0.0</spring.boot.version>
|
||||||
<kotlin.version>2.2.0</kotlin.version>
|
<kotlin.version>2.2.0</kotlin.version>
|
||||||
<jda.version>6.1.1</jda.version>
|
<jda.version>6.1.1</jda.version>
|
||||||
</properties>
|
</properties>
|
||||||
@@ -26,11 +21,28 @@
|
|||||||
</repository>
|
</repository>
|
||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
|
<version>${spring.boot.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<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>
|
||||||
@@ -59,10 +71,23 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>${spring.boot.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<skip>true</skip>
|
||||||
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
<artifactId>kotlin-maven-plugin</artifactId>
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>compile</id>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
<configuration>
|
<configuration>
|
||||||
<args>
|
<args>
|
||||||
<arg>-Xjsr305=strict</arg>
|
<arg>-Xjsr305=strict</arg>
|
||||||
|
|||||||
@@ -4,20 +4,20 @@ import net.dv8tion.jda.api.interactions.commands.build.SubcommandGroupData
|
|||||||
import net.dv8tion.jda.internal.interactions.CommandDataImpl
|
import net.dv8tion.jda.internal.interactions.CommandDataImpl
|
||||||
|
|
||||||
fun Command.toCommandData(): CommandDataImpl = CommandDataImpl(name, description).apply {
|
fun Command.toCommandData(): CommandDataImpl = CommandDataImpl(name, description).apply {
|
||||||
addOptions(options)
|
addOptions(this@toCommandData.options)
|
||||||
neededPermissions?.let { setDefaultPermissions(it) }
|
this@toCommandData.neededPermissions?.let { setDefaultPermissions(it) }
|
||||||
|
|
||||||
if (subcommands.isNotEmpty()) {
|
if (this@toCommandData.subcommands.isNotEmpty()) {
|
||||||
addSubcommands(subcommands.map { toSubcommandData() })
|
addSubcommands(this@toCommandData.subcommands.map { it.toSubcommandData() })
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subcommandGroups.isNotEmpty()) {
|
if (this@toCommandData.subcommandGroups.isNotEmpty()) {
|
||||||
addSubcommandGroups(
|
addSubcommandGroups(
|
||||||
subcommandGroups.map { group ->
|
this@toCommandData.subcommandGroups.map { group ->
|
||||||
SubcommandGroupData(
|
SubcommandGroupData(
|
||||||
group.name,
|
group.name,
|
||||||
group.description
|
group.description
|
||||||
).addSubcommands(group.subcommands.map { toSubcommandData() })
|
).addSubcommands(group.subCommands.map { it.toSubcommandData() })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -10,4 +10,5 @@ class JdaConfiguration {
|
|||||||
var onlineStatus: OnlineStatus = OnlineStatus.ONLINE
|
var onlineStatus: OnlineStatus = OnlineStatus.ONLINE
|
||||||
var cacheFlags: Set<CacheFlag> = emptySet()
|
var cacheFlags: Set<CacheFlag> = emptySet()
|
||||||
var activity: String? = null
|
var activity: String? = null
|
||||||
|
var guildId: String? = null
|
||||||
}
|
}
|
||||||
@@ -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,
|
||||||
@@ -59,9 +55,16 @@ class JdaService(
|
|||||||
|
|
||||||
val commandDataList = contextCommands.map { it.toCommandData() }
|
val commandDataList = contextCommands.map { it.toCommandData() }
|
||||||
|
|
||||||
jda.updateCommands()
|
if (jdaConfiguration.guildId != null) {
|
||||||
.addCommands(commandDataList)
|
jda.getGuildById(jdaConfiguration.guildId!!)
|
||||||
.queue()
|
?.updateCommands()
|
||||||
|
?.addCommands(commandDataList)
|
||||||
|
?.queue()
|
||||||
|
} else {
|
||||||
|
jda.updateCommands()
|
||||||
|
.addCommands(commandDataList)
|
||||||
|
.queue()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventListener(SlashCommandInteractionEvent::class)
|
@EventListener(SlashCommandInteractionEvent::class)
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fr.lucasdupont.configuration.JdaAutoConfiguration
|
||||||
|
|
||||||
Reference in New Issue
Block a user