Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to KordEx v2 #114

Merged
merged 11 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v1
Expand All @@ -30,21 +30,21 @@ jobs:
arguments: build

- name: Upload artifacts (Main JAR)
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4

with:
name: Main JAR
path: build/libs/*-all.jar

- name: Upload artifacts (JARs)
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4

with:
name: JARs
path: build/libs/*.jar

- name: Upload artifacts (Module JARs)
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4

with:
name: Module JARs
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v1
Expand All @@ -27,21 +27,21 @@ jobs:
arguments: build

- name: Upload artifacts (Main JAR)
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4

with:
name: Main JAR
path: build/libs/*-all.jar

- name: Upload artifacts (JARs)
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4

with:
name: JARs
path: build/libs/*.jar

- name: Upload artifacts (Module JARs)
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4

with:
name: Module JARs
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/root.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v1
Expand All @@ -28,21 +28,21 @@ jobs:
arguments: build

- name: Upload artifacts (Main JAR)
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4

with:
name: Main JAR
path: build/libs/*-all.jar

- name: Upload artifacts (JARs)
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4

with:
name: JARs
path: build/libs/*.jar

- name: Upload artifacts (Module JARs)
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4

with:
name: Module JARs
Expand Down
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ FROM openjdk:17-jdk-slim
COPY build/libs/CozyDiscord-*-all.jar /usr/local/lib/CozyDiscord.jar

RUN mkdir /bot
RUN mkdir /bot/data
RUN mkdir /bot/plugins
RUN mkdir /data

WORKDIR /bot

VOLUME /bot/data
VOLUME /bot/plugins

ENTRYPOINT ["java", "-Xms2G", "-Xmx2G", "-jar", "/usr/local/lib/CozyDiscord.jar"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ ENVIRONMENT=dev

* `GITHUB_TOKEN`: GitHub auth token, for the GitHub project management commands

Once you've filled out your `.env` file, you can use the `run` gradle task to launch the bot. If this is your first
Once you've filled out your `.env` file, you can use the `dev` gradle task to launch the bot. If this is your first
run, you'll want to start with the `quilt` mode as this is the mode that runs the database migrations. After that,
feel free to set up and test whichever mode you need to work with.

Expand Down
21 changes: 13 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.expediagroup.graphql.plugin.gradle.config.GraphQLSerializer
import dev.kordex.gradle.plugins.kordex.DataCollection

/*
* This Source Code Form is subject to the terms of the Mozilla Public
Expand Down Expand Up @@ -52,17 +53,21 @@ dependencies {
}

kordEx {
version = "2.2.1-SNAPSHOT"

bot {
dataCollection(DataCollection.Minimal)

mainClass = "org.quiltmc.community.AppKt"
}

module("annotations")
module("extra-mappings")
module("extra-phishing")
module("extra-pluralkit")
module("extra-tags")
module("extra-welcome")
module("unsafe")
module("dev-unsafe")

module("func-phishing")
module("func-tags")
module("func-welcome")

module("pluralkit")
}

graphql {
Expand All @@ -76,7 +81,7 @@ graphql {

gitHooks {
setHooks(
mapOf("pre-commit" to "updateLicense detekt")
mapOf("pre-commit" to "applyLicenses detekt")
)
}

Expand Down
8 changes: 4 additions & 4 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ dependencies {
implementation(gradleApi())
implementation(localGroovy())

implementation(kotlin("gradle-plugin", version = "2.0.20-Beta1"))
implementation(kotlin("serialization", version = "2.0.20-Beta1"))
implementation(kotlin("gradle-plugin", version = "2.0.20"))
implementation(kotlin("serialization", version = "2.0.20"))

implementation("com.github.jakemarsden", "git-hooks-gradle-plugin", "0.0.2")
implementation("com.expediagroup.graphql", "com.expediagroup.graphql.gradle.plugin", "7.1.4")
implementation("com.github.johnrengelman.shadow", "com.github.johnrengelman.shadow.gradle.plugin", "8.1.1")
implementation("com.google.devtools.ksp", "com.google.devtools.ksp.gradle.plugin", "2.0.20-Beta1-1.0.22")
implementation("dev.kordex.gradle.plugins", "kordex", "1.1.3")
implementation("com.google.devtools.ksp", "com.google.devtools.ksp.gradle.plugin", "2.0.20-1.0.24")
implementation("dev.kordex.gradle.plugins", "kordex", "1.4.1")
implementation("dev.yumi", "yumi-gradle-licenser", "1.2.0")
implementation("io.gitlab.arturbosch.detekt", "detekt-gradle-plugin", "1.23.6")
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/cozy-module.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ plugins {
}

group = "org.quiltmc.community"
version = "1.0.1-SNAPSHOT"
version = "1.1.0-SNAPSHOT"

repositories {
maven {
Expand Down
5 changes: 1 addition & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
detekt = "1.23.6"
kotlin = "2.0.20-Beta1"
kotlin = "2.0.20"
graphql = "7.1.4"

autolink = "0.11.0"
Expand All @@ -19,7 +19,6 @@ kx-ser = "1.7.1"
logback = "1.5.6"
logback-groovy = "1.14.5"
logging = "7.0.0"
moshi = "1.15.1"
rgxgen = "2.0"
semver = "2.0.0"

Expand Down Expand Up @@ -49,7 +48,5 @@ kx-ser = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.
logback = { module = "ch.qos.logback:logback-classic", version.ref = "logback" }
logback-groovy = { module = "io.github.virtualdogbert:logback-groovy-config", version.ref = "logback-groovy" }
logging = { module = "io.github.oshai:kotlin-logging", version.ref = "logging" }
moshi-adapters = { module = "com.squareup.moshi:moshi-adapters", version.ref = "moshi" }
moshi-kotlin = { module = "com.squareup.moshi:moshi-kotlin", version.ref = "moshi" }
rgxgen = { module = "com.github.curious-odd-man:rgxgen", version.ref = "rgxgen" }
semver = { module = "io.github.z4kn4fein:semver", version.ref = "semver" }
5 changes: 2 additions & 3 deletions module-ama/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dependencies {
}

kordEx {
module("annotations")
module("extra-pluralkit")
module("unsafe")
module("pluralkit")
module("dev-unsafe")
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,6 @@

package org.quiltmc.community.cozy.modules.ama

import com.kotlindiscord.kord.extensions.checks.anyGuild
import com.kotlindiscord.kord.extensions.checks.guildFor
import com.kotlindiscord.kord.extensions.commands.Arguments
import com.kotlindiscord.kord.extensions.commands.application.slash.ephemeralSubCommand
import com.kotlindiscord.kord.extensions.commands.converters.impl.channel
import com.kotlindiscord.kord.extensions.commands.converters.impl.optionalChannel
import com.kotlindiscord.kord.extensions.components.ComponentRegistry
import com.kotlindiscord.kord.extensions.components.components
import com.kotlindiscord.kord.extensions.components.ephemeralButton
import com.kotlindiscord.kord.extensions.components.forms.ModalForm
import com.kotlindiscord.kord.extensions.components.forms.widgets.LineTextWidget
import com.kotlindiscord.kord.extensions.components.forms.widgets.ParagraphTextWidget
import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.ephemeralSlashCommand
import com.kotlindiscord.kord.extensions.extensions.event
import com.kotlindiscord.kord.extensions.modules.unsafe.annotations.UnsafeAPI
import com.kotlindiscord.kord.extensions.modules.unsafe.extensions.unsafeSlashCommand
import com.kotlindiscord.kord.extensions.modules.unsafe.types.InitialSlashCommandResponse
import com.kotlindiscord.kord.extensions.modules.unsafe.types.ackEphemeral
import com.kotlindiscord.kord.extensions.modules.unsafe.types.respondEphemeral
import dev.kord.common.entity.ButtonStyle
import dev.kord.common.entity.ChannelType
import dev.kord.common.entity.Permission
Expand All @@ -47,6 +27,24 @@ import dev.kord.core.entity.channel.GuildMessageChannel
import dev.kord.core.entity.channel.TopGuildChannel
import dev.kord.core.event.interaction.GuildButtonInteractionCreateEvent
import dev.kord.rest.builder.message.embed
import dev.kordex.core.checks.anyGuild
import dev.kordex.core.checks.guildFor
import dev.kordex.core.commands.Arguments
import dev.kordex.core.commands.application.slash.ephemeralSubCommand
import dev.kordex.core.commands.converters.impl.channel
import dev.kordex.core.commands.converters.impl.optionalChannel
import dev.kordex.core.components.ComponentRegistry
import dev.kordex.core.components.components
import dev.kordex.core.components.ephemeralButton
import dev.kordex.core.components.forms.ModalForm
import dev.kordex.core.components.forms.widgets.LineTextWidget
import dev.kordex.core.components.forms.widgets.ParagraphTextWidget
import dev.kordex.core.extensions.Extension
import dev.kordex.core.extensions.ephemeralSlashCommand
import dev.kordex.core.extensions.event
import dev.kordex.modules.dev.unsafe.annotations.UnsafeAPI
import dev.kordex.modules.dev.unsafe.commands.slash.InitialSlashCommandResponse
import dev.kordex.modules.dev.unsafe.extensions.unsafeSlashCommand
import org.koin.core.component.inject
import org.quiltmc.community.cozy.modules.ama.data.AmaConfig
import org.quiltmc.community.cozy.modules.ama.data.AmaData
Expand Down Expand Up @@ -435,6 +433,7 @@ public class AmaExtension : Extension() {
name = "answer-queue-channel"
description = "The channel for asked questions to queue up in before response"
requiredChannelTypes = mutableSetOf(ChannelType.GuildText)

validate {
val checkResult = value.checkPermission(Permissions(Permission.ViewChannel, Permission.SendMessages))
failIf(checkResult == false, "The bot cannot see this channel")
Expand All @@ -446,6 +445,7 @@ public class AmaExtension : Extension() {
name = "live-chat-channel"
description = "The channel questions will be sent to when answered by staff"
requiredChannelTypes = mutableSetOf(ChannelType.GuildText)

validate {
val checkResult = value.checkPermission(Permissions(Permission.ViewChannel, Permission.SendMessages))
failIf(checkResult == false, "The bot cannot see this channel")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

package org.quiltmc.community.cozy.modules.ama

import com.kotlindiscord.kord.extensions.modules.extra.pluralkit.api.PKMemberPrivacy
import com.kotlindiscord.kord.extensions.modules.extra.pluralkit.api.PKProxyTag
import com.kotlindiscord.kord.extensions.modules.extra.pluralkit.api.PKSystem
import com.kotlindiscord.kord.extensions.utils.envOrNull
import com.kotlindiscord.kord.extensions.utils.getKoin
import dev.kord.common.Color
import dev.kord.common.entity.optional.Optional
import dev.kord.core.behavior.UserBehavior
import dev.kordex.core.utils.envOrNull
import dev.kordex.core.utils.getKoin
import dev.kordex.modules.pluralkit.api.PKMemberPrivacy
import dev.kordex.modules.pluralkit.api.PKProxyTag
import dev.kordex.modules.pluralkit.api.PKSystem
import io.ktor.client.*
import io.ktor.client.call.*
import io.ktor.client.plugins.contentnegotiation.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@

package org.quiltmc.community.cozy.modules.ama

import com.kotlindiscord.kord.extensions.DISCORD_BLURPLE
import com.kotlindiscord.kord.extensions.DISCORD_GREEN
import com.kotlindiscord.kord.extensions.DISCORD_RED
import com.kotlindiscord.kord.extensions.DISCORD_YELLOW
import com.kotlindiscord.kord.extensions.builders.ExtensibleBotBuilder
import com.kotlindiscord.kord.extensions.components.ComponentContainer
import com.kotlindiscord.kord.extensions.components.components
import com.kotlindiscord.kord.extensions.components.ephemeralButton
import com.kotlindiscord.kord.extensions.utils.loadModule
import dev.kord.common.Color
import dev.kord.common.entity.ButtonStyle
import dev.kord.common.entity.Snowflake
Expand All @@ -26,6 +17,15 @@ import dev.kord.core.entity.User
import dev.kord.core.entity.channel.GuildMessageChannel
import dev.kord.rest.builder.message.EmbedBuilder
import dev.kord.rest.builder.message.embed
import dev.kordex.core.DISCORD_BLURPLE
import dev.kordex.core.DISCORD_GREEN
import dev.kordex.core.DISCORD_RED
import dev.kordex.core.DISCORD_YELLOW
import dev.kordex.core.builders.ExtensionsBuilder
import dev.kordex.core.components.ComponentContainer
import dev.kordex.core.components.components
import dev.kordex.core.components.ephemeralButton
import dev.kordex.core.utils.loadModule
import kotlinx.serialization.KSerializer
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
Expand All @@ -36,7 +36,7 @@ import org.koin.dsl.bind
import org.quiltmc.community.cozy.modules.ama.data.AmaData
import org.quiltmc.community.cozy.modules.ama.enums.QuestionStatusFlag

public fun ExtensibleBotBuilder.ExtensionsBuilder.extAma(data: AmaData) {
public fun ExtensionsBuilder.extAma(data: AmaData) {
loadModule { single { data } bind AmaData::class }

add(::AmaExtension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

package org.quiltmc.community.cozy.modules.ama.data

import com.kotlindiscord.kord.extensions.checks.hasPermission
import com.kotlindiscord.kord.extensions.checks.types.CheckContextWithCache
import dev.kord.common.entity.Permission
import dev.kord.common.entity.Snowflake
import dev.kordex.core.checks.hasPermission
import dev.kordex.core.checks.types.CheckContextWithCache

public interface AmaData {
public suspend fun getConfig(guildId: Snowflake): AmaConfig?
Expand Down
5 changes: 2 additions & 3 deletions module-log-parser/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ dependencies {
}

kordEx {
module("annotations")
module("extra-pluralkit")
module("unsafe")
module("pluralkit")
module("dev-unsafe")
}
Loading
Loading