-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Begin work on storing original permissions when locking channels
- Loading branch information
1 parent
8799f52
commit bb61a66
Showing
4 changed files
with
78 additions
and
42 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/main/kotlin/org/hyacinthbots/lilybot/database/collections/LockedChannelCollection.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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) | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/kotlin/org/hyacinthbots/lilybot/database/entities/LockedChannelData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.hyacinthbots.lilybot.database.entities | ||
|
||
import dev.kord.common.entity.Permissions | ||
import dev.kord.common.entity.Snowflake | ||
import kotlinx.serialization.Contextual | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class LockedChannelData( | ||
val guildId: Snowflake, | ||
val channelId: Snowflake, | ||
@Contextual val allowed: Permissions, | ||
@Contextual val denied: Permissions, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters