Skip to content

Commit

Permalink
guild command -> global command
Browse files Browse the repository at this point in the history
fixes bug with commands not being available when joining afterwards
  • Loading branch information
Zabuzard committed Mar 1, 2023
1 parent 12b0f9d commit fc508c7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = "io.github.zabuzard.discordplays"
version = "2.1-SNAPSHOT"
version = "2.2-SNAPSHOT"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,25 @@ package io.github.zabuzard.discordplays.discord.commands
import dev.kord.common.entity.Permission
import dev.kord.common.entity.Permissions
import dev.kord.core.Kord
import dev.kord.core.behavior.createApplicationCommands
import dev.kord.rest.builder.interaction.GuildMultiApplicationCommandBuilder
import dev.kord.rest.builder.interaction.GlobalMultiApplicationCommandBuilder
import dev.kord.rest.builder.interaction.boolean
import dev.kord.rest.builder.interaction.string
import dev.kord.rest.builder.interaction.subCommand
import dev.kord.rest.builder.interaction.user
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.launch
import org.apache.logging.log4j.Level

fun Kord.registerCommands() {
launch {
guilds.toList().forEach {
it.createApplicationCommands {
hostCommands()
ownerCommands()
}.collect()
}
createGlobalApplicationCommands {
hostCommands()
ownerCommands()
}.collect()
}
}

private fun GuildMultiApplicationCommandBuilder.hostCommands() {
private fun GlobalMultiApplicationCommandBuilder.hostCommands() {
input(HOST_COMMAND_NAME, "commands for streaming the event in your community") {
defaultMemberPermissions = Permissions(Permission.ModerateMembers)

Expand All @@ -42,7 +38,7 @@ private fun GuildMultiApplicationCommandBuilder.hostCommands() {
}
}

private fun GuildMultiApplicationCommandBuilder.ownerCommands() {
private fun GlobalMultiApplicationCommandBuilder.ownerCommands() {
input(COMMAND_NAME, "commands for managing the event") {
defaultMemberPermissions = Permissions(Permission.Administrator)

Expand Down

0 comments on commit fc508c7

Please sign in to comment.