Skip to content

Commit

Permalink
Update to latest KordEx snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
gdude2002 committed Aug 3, 2021
1 parent dd428e2 commit 77bbba1
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import dev.kord.core.entity.Member
import dev.kord.core.entity.Message
import dev.kord.core.entity.User
import dev.kord.core.event.message.MessageCreateEvent
import dev.kord.rest.builder.message.MessageCreateBuilder
import dev.kord.rest.builder.message.create.MessageCreateBuilder

/**
* Command context object representing the context given to message commands.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import dev.kord.core.entity.interaction.CommandInteraction
import dev.kord.core.entity.interaction.InteractionFollowup
import dev.kord.core.entity.interaction.PublicFollowupMessage
import dev.kord.core.event.interaction.InteractionCreateEvent
import dev.kord.rest.builder.interaction.EphemeralFollowupMessageCreateBuilder
import dev.kord.rest.builder.interaction.FollowupMessageBuilder
import dev.kord.rest.builder.interaction.PublicFollowupMessageCreateBuilder
import dev.kord.rest.builder.message.create.EphemeralFollowupMessageCreateBuilder
import dev.kord.rest.builder.message.create.MessageCreateBuilder
import dev.kord.rest.builder.message.create.PublicFollowupMessageCreateBuilder
import dev.kord.rest.builder.message.modify.MessageModifyBuilder

/**
* Command context object representing the context given to message commands.
Expand Down Expand Up @@ -176,7 +177,27 @@ public open class SlashCommandContext<T : Arguments>(
*
* @see Components
*/
public suspend fun FollowupMessageBuilder<*>.components(
public suspend fun MessageCreateBuilder.components(
timeoutSeconds: Long? = null,
body: suspend Components.() -> Unit
): Components {
val components = Components(command.extension, this@SlashCommandContext)

body(components)

with(components) {
setup(timeoutSeconds)
}

return components
}

/**
* Convenience function for adding components to your message via the [Components] class.
*
* @see Components
*/
public suspend fun MessageModifyBuilder.components(
timeoutSeconds: Long? = null,
body: suspend Components.() -> Unit
): Components {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import dev.kord.common.annotation.KordPreview
import dev.kord.core.Kord
import dev.kord.core.entity.interaction.ComponentInteraction
import dev.kord.core.event.interaction.InteractionCreateEvent
import dev.kord.rest.builder.interaction.FollowupMessageBuilder
import dev.kord.rest.builder.interaction.actionRow
import dev.kord.rest.builder.message.MessageCreateBuilder
import dev.kord.rest.builder.message.MessageModifyBuilder
import dev.kord.rest.builder.message.create.MessageCreateBuilder
import dev.kord.rest.builder.message.create.actionRow
import dev.kord.rest.builder.message.modify.MessageModifyBuilder
import dev.kord.rest.builder.message.modify.actionRow
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -293,20 +293,4 @@ public open class Components(

startListening(timeoutSeconds)
}

/**
* @suppress Internal API function that sets up all of the components, adds them to the message, and listens for
* interactions.
*/
public open suspend fun FollowupMessageBuilder<*>.setup(timeoutSeconds: Long? = null) {
sortIntoRows()

for (row in rows.filter { row -> row.isNotEmpty() }) {
actionRow {
row.forEach { it.apply(this) }
}
}

startListening(timeoutSeconds)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import dev.kord.core.entity.interaction.ComponentInteraction
import dev.kord.core.entity.interaction.InteractionFollowup
import dev.kord.core.entity.interaction.PublicFollowupMessage
import dev.kord.core.event.interaction.InteractionCreateEvent
import dev.kord.rest.builder.interaction.EphemeralFollowupMessageCreateBuilder
import dev.kord.rest.builder.interaction.PublicFollowupMessageCreateBuilder
import dev.kord.rest.builder.message.create.EphemeralFollowupMessageCreateBuilder
import dev.kord.rest.builder.message.create.PublicFollowupMessageCreateBuilder
import io.sentry.Breadcrumb
import io.sentry.SentryLevel
import org.koin.core.component.KoinComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import dev.kord.core.behavior.interaction.edit
import dev.kord.core.entity.ReactionEmoji
import dev.kord.core.entity.User
import dev.kord.core.entity.interaction.PublicFollowupMessage
import dev.kord.rest.builder.interaction.embed
import dev.kord.rest.builder.message.create.embed
import dev.kord.rest.builder.message.modify.embed
import java.util.*

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import dev.kord.core.behavior.edit
import dev.kord.core.entity.Message
import dev.kord.core.entity.ReactionEmoji
import dev.kord.core.entity.User
import dev.kord.rest.builder.message.create.allowedMentions
import dev.kord.rest.builder.message.create.embed
import dev.kord.rest.builder.message.modify.allowedMentions
import dev.kord.rest.builder.message.modify.embed
import java.util.*

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import dev.kord.core.entity.channel.DmChannel
import dev.kord.core.event.Event
import dev.kord.core.event.message.ReactionAddEvent
import dev.kord.core.event.message.ReactionRemoveEvent
import dev.kord.rest.builder.message.create.embed
import dev.kord.rest.builder.message.modify.embed
import kotlinx.coroutines.delay
import mu.KotlinLogging
import org.koin.core.component.KoinComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import dev.kord.core.entity.*
import dev.kord.core.entity.channel.DmChannel
import dev.kord.core.entity.channel.GuildMessageChannel
import dev.kord.core.event.message.*
import dev.kord.rest.builder.message.MessageCreateBuilder
import dev.kord.rest.builder.message.create.MessageCreateBuilder
import dev.kord.rest.builder.message.create.allowedMentions
import dev.kord.rest.request.RestRequestException
import io.ktor.http.*
import kotlinx.coroutines.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import dev.kord.core.behavior.channel.createMessage
import dev.kord.core.entity.Message
import dev.kord.core.entity.Role
import dev.kord.core.entity.User
import dev.kord.rest.builder.message.MessageCreateBuilder
import dev.kord.rest.builder.message.create.MessageCreateBuilder
import dev.kord.rest.request.RestRequestException
import io.ktor.http.*
import kotlinx.datetime.Instant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import dev.kord.common.entity.ButtonStyle
import dev.kord.common.entity.Permission
import dev.kord.core.behavior.channel.createEmbed
import dev.kord.core.behavior.reply
import dev.kord.rest.builder.interaction.embed
import dev.kord.rest.builder.message.create.embed

// They're IDs
@Suppress("UnderscoresInNumericLiterals")
Expand Down

0 comments on commit 77bbba1

Please sign in to comment.