Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a44d987042 | ||
|
|
67e4f971bc | ||
|
|
29a419a560 | ||
|
|
eddd857a20 |
14
CHANGELOG.md
14
CHANGELOG.md
@@ -1,3 +1,17 @@
|
|||||||
|
## [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)
|
# [1.2.0](https://git.tools.ldpt.fr/lucasdpt/spring-jda-starter/compare/1.1.0...1.2.0) (2025-12-16)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>fr.lucasdupont</groupId>
|
<groupId>fr.lucasdupont</groupId>
|
||||||
<artifactId>spring-jda-starter</artifactId>
|
<artifactId>spring-jda-starter</artifactId>
|
||||||
<version>1.2.0</version>
|
<version>1.3.1</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>21</java.version>
|
<java.version>21</java.version>
|
||||||
|
|||||||
@@ -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() })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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
|
||||||
}
|
}
|
||||||
@@ -55,10 +55,17 @@ class JdaService(
|
|||||||
|
|
||||||
val commandDataList = contextCommands.map { it.toCommandData() }
|
val commandDataList = contextCommands.map { it.toCommandData() }
|
||||||
|
|
||||||
|
if (jdaConfiguration.guildId != null) {
|
||||||
|
jda.getGuildById(jdaConfiguration.guildId!!)
|
||||||
|
?.updateCommands()
|
||||||
|
?.addCommands(commandDataList)
|
||||||
|
?.queue()
|
||||||
|
} else {
|
||||||
jda.updateCommands()
|
jda.updateCommands()
|
||||||
.addCommands(commandDataList)
|
.addCommands(commandDataList)
|
||||||
.queue()
|
.queue()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventListener(SlashCommandInteractionEvent::class)
|
@EventListener(SlashCommandInteractionEvent::class)
|
||||||
fun onSlashCommand(event: SlashCommandInteractionEvent) {
|
fun onSlashCommand(event: SlashCommandInteractionEvent) {
|
||||||
|
|||||||
Reference in New Issue
Block a user