-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
LockedChannelCollection.kt
24 lines (18 loc) · 1.04 KB
/
LockedChannelCollection.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package org.hyacinthbots.lilybot.database.collections
import com.kotlindiscord.kord.extensions.koin.KordExKoinComponent
import dev.kord.common.entity.Snowflake
import org.hyacinthbots.lilybot.database.Database
import org.hyacinthbots.lilybot.database.entities.LockedChannelData
import org.koin.core.component.inject
import org.litote.kmongo.eq
class LockedChannelCollection : KordExKoinComponent {
private val db: Database by inject()
@PublishedApi
internal val collection = db.mainDatabase.getCollection<LockedChannelData>()
suspend inline fun addLockedChannel(data: LockedChannelData) =
collection.insertOne(data)
suspend inline fun removeLockedChannel(inputGuildId: Snowflake, inputChannelId: Snowflake) =
collection.deleteOne(LockedChannelData::guildId eq inputGuildId, LockedChannelData::channelId eq inputChannelId)
suspend inline fun getLockedChannel(inputGuildId: Snowflake, inputChannelId: Snowflake): LockedChannelData? =
collection.findOne(LockedChannelData::guildId eq inputGuildId, LockedChannelData::channelId eq inputChannelId)
}