-
-
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.
Merge pull request #341 from HyacinthBots/develop
4.8.0
- Loading branch information
Showing
34 changed files
with
451 additions
and
45 deletions.
There are no files selected for viewing
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 @@ | ||
*.kt text eol=lf diff=kotlin | ||
*.kts text eol=lf diff=kotlin | ||
|
||
gradlew text eol=lf | ||
*.bat text eol=crlf | ||
|
||
*.md text eol=lf diff=markdown | ||
|
||
*.properties text eol=lf | ||
*.yml text eol=lf | ||
|
||
*.class binary | ||
*.jar binary | ||
*.png binary |
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
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 |
---|---|---|
|
@@ -27,6 +27,7 @@ jobs: | |
uses: gradle/gradle-build-action@v2 | ||
with: | ||
arguments: build --stacktrace | ||
gradle-home-cache-cleanup: true | ||
|
||
- name: Upload artifacts GitHub | ||
uses: AButler/[email protected] | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# LilyBot 4.8.0 | ||
|
||
This update fixes bugs and adds a couple of new features | ||
You can find the full changelog below | ||
|
||
New: | ||
* Automatically applies she-her and it-its roles to Lily when a pronoun role menu is created | ||
* Allow users to subscribe to roles in a similar fashion to role menus, but with commands | ||
|
||
Change: | ||
* Update to Kotlin 1.8.10, Gradle 8.0.1 and other dependencies (Internal) | ||
* Removed configDb parameter from migrations (Internal) | ||
|
||
Fix: | ||
* Remove deprecated kord functions (Internal) | ||
* Fix reminder IDs sometimes overlapping causing duplicate entries and errors | ||
|
||
You can find a list of all the commits in this update [here](https://github.com/hyacinthbots/LilyBot/compare/v4.6.3...v4.7.0) |
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
Binary file not shown.
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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
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
107 changes: 107 additions & 0 deletions
107
src/main/kotlin/org/hyacinthbots/lilybot/database/collections/RoleSubscriptionCollection.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,107 @@ | ||
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.RoleSubscriptionData | ||
import org.koin.core.component.inject | ||
import org.litote.kmongo.eq | ||
|
||
/** | ||
* This class contains the functions for interacting with the [Role Subscription database][RoleSubscriptionData]. This | ||
* class contains the functions for getting, adding, removing and clearing subscribable roles. | ||
* | ||
* @since 4.9.0 | ||
* @see getSubscribableRoles | ||
* @see createSubscribableRoleRecord | ||
* @see addSubscribableRole | ||
* @see removeSubscribableRole | ||
* @see removeAllSubscribableRoles | ||
*/ | ||
class RoleSubscriptionCollection : KordExKoinComponent { | ||
private val db: Database by inject() | ||
|
||
@PublishedApi | ||
internal val collection = db.mainDatabase.getCollection<RoleSubscriptionData>() | ||
|
||
/** | ||
* Gets the roles that are subscribable for a given guild. | ||
* | ||
* @param inputGuildId The guild to get the roles for | ||
* @return The [RoleSubscriptionData] for the guild | ||
* | ||
* @author NoComment1105 | ||
* @since 4.9.0 | ||
*/ | ||
suspend inline fun getSubscribableRoles(inputGuildId: Snowflake): RoleSubscriptionData? = | ||
collection.findOne(RoleSubscriptionData::guildId eq inputGuildId) | ||
|
||
/** | ||
* Creates a subscribable role record in the database. This should only be used if a record does not already exist. | ||
* | ||
* @param inputGuildId The ID of the guild to create the record for | ||
* | ||
* @author NoComment1105 | ||
* @since 4.9.0 | ||
*/ | ||
suspend inline fun createSubscribableRoleRecord(inputGuildId: Snowflake) = | ||
collection.insertOne(RoleSubscriptionData(inputGuildId, mutableListOf())) | ||
|
||
/** | ||
* Adds a role to the subscribable role list. | ||
* | ||
* @param inputGuildId The ID of the guild to add to the list | ||
* @param inputRoleId The ID of the role to add | ||
* @return True if the transaction was a success, false if it was not, null if the collection does not exist | ||
* | ||
* @author NoComment1105 | ||
* @since 4.9.0 | ||
*/ | ||
suspend inline fun addSubscribableRole(inputGuildId: Snowflake, inputRoleId: Snowflake): Boolean? { | ||
val col = collection.findOne(RoleSubscriptionData::guildId eq inputGuildId) ?: return null | ||
val newRoleList = col.subscribableRoles | ||
if (newRoleList.contains(inputRoleId)) return false else newRoleList.add(inputRoleId) | ||
collection.updateOne( | ||
RoleSubscriptionData::guildId eq inputGuildId, | ||
RoleSubscriptionData(inputGuildId, newRoleList) | ||
) | ||
return true | ||
} | ||
|
||
/** | ||
* Removes a role to the subscribable role list. | ||
* | ||
* @param inputGuildId The ID of the guild to alter the list of | ||
* @param inputRoleId The ID of the role to rem,ove | ||
* @return True if the transaction was a success, false if it was not, null if the collection does not exist | ||
* | ||
* @author NoComment1105 | ||
* @since 4.9.0 | ||
*/ | ||
suspend inline fun removeSubscribableRole(inputGuildId: Snowflake, inputRoleId: Snowflake): Boolean? { | ||
val col = collection.findOne(RoleSubscriptionData::guildId eq inputGuildId) ?: return null | ||
val newRoleList = col.subscribableRoles | ||
if (!newRoleList.contains(inputRoleId)) { | ||
return false | ||
} else { | ||
val removal = newRoleList.remove(inputRoleId) | ||
if (!removal) return false | ||
} | ||
collection.updateOne( | ||
RoleSubscriptionData::guildId eq inputGuildId, | ||
RoleSubscriptionData(inputGuildId, newRoleList) | ||
) | ||
return true | ||
} | ||
|
||
/** | ||
* Removes all subscribable roles for a guild. | ||
* | ||
* @param inputGuildId The ID of the guild to remove subscribable roles for | ||
* | ||
* @author NoComment1105 | ||
* @since 4.9.0 | ||
*/ | ||
suspend inline fun removeAllSubscribableRoles(inputGuildId: Snowflake) = | ||
collection.deleteOne(RoleSubscriptionData::guildId eq inputGuildId) | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/org/hyacinthbots/lilybot/database/entities/RoleSubscriptionData.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,17 @@ | ||
package org.hyacinthbots.lilybot.database.entities | ||
|
||
import dev.kord.common.entity.Snowflake | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* The data for role subscriptions. | ||
* | ||
* @property guildId The ID of the guild the subscription roles are for | ||
* @property subscribableRoles The roles that can be subscribed too. | ||
* @since 4.9.0 | ||
*/ | ||
@Serializable | ||
data class RoleSubscriptionData( | ||
val guildId: Snowflake, | ||
val subscribableRoles: MutableList<Snowflake> | ||
) |
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
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
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
Oops, something went wrong.