This commit is contained in:
parent
3ec90b83b2
commit
78572ef176
@ -3,9 +3,18 @@ package dev.jansel.aglaea.utils
|
||||
import com.github.philippheuer.credentialmanager.domain.OAuth2Credential
|
||||
import com.github.twitch4j.TwitchClientBuilder
|
||||
import com.github.twitch4j.chat.events.channel.ChannelMessageEvent
|
||||
import dev.jansel.aglaea.botRef
|
||||
import dev.jansel.aglaea.database.collections.ReplayCollection
|
||||
import dev.jansel.aglaea.logger
|
||||
import dev.jansel.aglaea.twitchClient
|
||||
import dev.kord.common.entity.Snowflake
|
||||
import dev.kord.core.behavior.channel.createMessage
|
||||
import dev.kord.core.entity.channel.GuildMessageChannel
|
||||
import dev.kordex.core.koin.KordExKoinComponent
|
||||
import io.ktor.client.request.forms.*
|
||||
import io.ktor.utils.io.*
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
||||
class Twitch : KordExKoinComponent {
|
||||
suspend fun init() {
|
||||
@ -23,6 +32,17 @@ class Twitch : KordExKoinComponent {
|
||||
twitchClient!!.eventManager.onEvent(ChannelMessageEvent::class.java) { event ->
|
||||
if (event.customRewardId.isPresent && event.customRewardId.get() == "38157e62-de35-4a21-8200-447b55d7577e") {
|
||||
logger.info { "Channel points redeemed: ${event.customRewardId.get()}" }
|
||||
runBlocking {
|
||||
launch {
|
||||
// Send a message to the channel
|
||||
val channel = botRef!!.kordRef.getChannelOf<GuildMessageChannel>(Snowflake(1130954956892029060))
|
||||
val replay = ReplayCollection().get(event.message)
|
||||
channel!!.createMessage {
|
||||
content = "Channel points redeemed: ${event.customRewardId.get()}"
|
||||
this.addFile("replay.osr", ChannelProvider(null) { ByteReadChannel(replay!!.replayFile) })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user