Skip to content

Commit

Permalink
Implement Stage instances (#291)
Browse files Browse the repository at this point in the history
* Add low-level implementation of stage instances

* Add helper functions

* Add core entities and api representations

* Expose creation of StageInstanceBehavior to unsafe
- Revert outdated change

* Final additions
- Add StageInstanceBehavior.asStageInstance
- Fix compiler issue
- Add StageChannelBehavior.getStageInstance()

* Add StageInstances to EntitySupplier.kt

* Add StageInstances to EntitySupplier.kt

* Fix typo

* Apply requested changes
  • Loading branch information
DRSchlaubi authored and HopeBaron committed Jun 24, 2021
1 parent 552c54d commit ae610fa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion core/src/main/kotlin/Unsafe.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class Unsafe(private val kord: Kord) {
fun webhook(id: Snowflake): WebhookBehavior =
WebhookBehavior(id, kord)

fun stageInstance(id: Snowflake, channelId: Snowflake): StageInstanceBehavior = StageInstanceBehavior(
id, channelId, kord, kord.defaultSupplier
)

override fun toString(): String {
return "Unsafe"
}
Expand All @@ -87,5 +91,4 @@ class Unsafe(private val kord: Kord) {
): GlobalApplicationCommandBehavior =
GlobalApplicationCommandBehavior(applicationId, commandId, service)


}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package dev.kord.core.behavior.channel
import dev.kord.common.entity.Snowflake
import dev.kord.core.Kord
import dev.kord.core.cache.data.ChannelData
import dev.kord.core.entity.channel.VoiceChannel
import dev.kord.core.cache.data.StageInstanceData
import dev.kord.core.entity.StageInstance
import dev.kord.core.entity.channel.Channel
Expand Down Expand Up @@ -33,6 +32,7 @@ interface StageChannelBehavior : BaseVoiceChannelBehavior {
return StageChannelBehavior(id, guildId, kord, strategy.supply(kord))
}


suspend fun createStageInstance(topic: String): StageInstance {
val instance = kord.rest.stageInstance.createStageInstance(id, topic)
val data = StageInstanceData.from(instance)
Expand Down
4 changes: 4 additions & 0 deletions core/src/samples/kotlin/PingBot.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import dev.kord.core.Kord
import dev.kord.core.behavior.channel.createStageInstance
import dev.kord.core.behavior.channel.getStageInstance
import dev.kord.core.behavior.getChannelOf
import dev.kord.core.entity.channel.StageChannel
import dev.kord.core.event.message.MessageCreateEvent
import dev.kord.core.on

Expand Down

0 comments on commit ae610fa

Please sign in to comment.