Skip to content

Commit

Permalink
Fix Discord occasionally breaking
Browse files Browse the repository at this point in the history
(cherry picked from commit b3bc195)
  • Loading branch information
nicholasgrose committed Oct 20, 2024
1 parent b1f80ad commit fdef7aa
Show file tree
Hide file tree
Showing 23 changed files with 85 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Build artifacts
uses: gradle/actions/setup-gradle@v3
with:
arguments: build
arguments: shadowJar

# https://github.com/marketplace/actions/create-release
- name: Create release
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/pull_request_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Build artifacts
uses: gradle/actions/setup-gradle@v3
with:
arguments: build --stacktrace
arguments: shadowJar

ktlint:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -63,4 +63,3 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
detekt_config: config/detekt/detekt.yml
detekt_build_upon_default_config: true
reporter: github-pr-review
25 changes: 25 additions & 0 deletions .idea/jarRepositories.xml

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

2 changes: 1 addition & 1 deletion .idea/misc.xml

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

4 changes: 0 additions & 4 deletions .idea/modules/Gateway.main.iml

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

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

36 changes: 21 additions & 15 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import dev.kordex.gradle.plugins.kordex.DataCollection
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.kordex)
alias(libs.plugins.shadow)
alias(libs.plugins.run.paper)
alias(libs.plugins.ktlint)
Expand All @@ -14,6 +16,8 @@ plugins {
val version: String by project
val group: String by project

val jvmTargetVersion: String by project
val kotlinTargetVersion: String by project
val minecraftTestVersion: String by project

val ktlintVersion: String by project
Expand All @@ -25,39 +29,45 @@ project.version = version
repositories {
mavenCentral()
gradlePluginPortal()
maven("https://repo.kordex.dev/snapshots/")
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://s01.oss.sonatype.org/content/repositories/snapshots")
maven("https://jitpack.io")
}

dependencies {
compileOnly(libs.paper.api)
implementation(libs.bundles.hoplite)
implementation(libs.kaml)
implementation(libs.kordex)
implementation(libs.tegral)
}

ktlint {
version.set(ktlintVersion)
}

detekt {
config.from("config/detekt/detekt.yml")
buildUponDefaultConfig = true
toolVersion = detektVersion
}

java {
toolchain.languageVersion = JavaLanguageVersion.of(21)
ktlint {
version = ktlintVersion
}

kordEx {
jvmTarget = jvmTargetVersion.toInt()

bot {
// See https://docs.kordex.dev/data-collection.html
dataCollection(DataCollection.Standard)

mainClass = "com.rose.gateway.discord.bot.DiscordBotKt"
}
}

tasks {
compileKotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_21
apiVersion = KotlinVersion.KOTLIN_2_0
languageVersion = KotlinVersion.KOTLIN_2_0
jvmTarget = JvmTarget.fromTarget(jvmTargetVersion)
apiVersion = KotlinVersion.fromVersion(kotlinTargetVersion)
languageVersion = KotlinVersion.fromVersion(kotlinTargetVersion)
}
}

Expand All @@ -80,10 +90,6 @@ tasks {
mergeServiceFiles()
}

build {
dependsOn(shadowJar)
}

runServer {
this.minecraftVersion(minecraftTestVersion)
}
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Project info
version=1.6.3
group=com.rose.gateway
# Target versions for compiled app
jvmTargetVersion=21
kotlinTargetVersion=2.0
# Version to use for testing
minecraftTestVersion=1.21.1
# Code style configuration
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ paper-api = "1.21.1-R0.1-SNAPSHOT"
hoplite = "2.8.2"
# https://github.com/charleskorn/kaml
kaml = "0.61.0"
# https://kordex.kotlindiscord.com/
kordex = "1.9.0-SNAPSHOT"
# https://docs.kordex.dev/getting-started
kordexPlugin = "1.4.2"
# https://tegral.zoroark.guru/docs/modules/core/niwen/
tegral = "0.0.4"

Expand All @@ -34,7 +34,6 @@ paper-api = { group = "io.papermc.paper", name = "paper-api", version.ref = "pap
hoplite-core = { group = "com.sksamuel.hoplite", name = "hoplite-core", version.ref = "hoplite" }
hoplite-yaml = { group = "com.sksamuel.hoplite", name = "hoplite-yaml", version.ref = "hoplite" }
kaml = { group = "com.charleskorn.kaml", name = "kaml", version.ref = "kaml" }
kordex = { group = "com.kotlindiscord.kord.extensions", name = "kord-extensions", version.ref = "kordex" }
tegral = { group = "guru.zoroark.tegral", name = "tegral-niwen-lexer", version.ref = "tegral" }

[bundles]
Expand All @@ -43,6 +42,7 @@ hoplite = ["hoplite-core", "hoplite-yaml"]
[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
kordex = { id = "dev.kordex.gradle.kordex", version.ref = "kordexPlugin" }
shadow = { id = "com.gradleup.shadow", version.ref = "shadow" }
run-paper = { id = "xyz.jpenilla.run-paper", version.ref = "runPaper" }
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint-plugin" }
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/com/rose/gateway/discord/bot/DiscordBot.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.rose.gateway.discord.bot

import com.kotlindiscord.kord.extensions.ExtensibleBot
import com.kotlindiscord.kord.extensions.utils.loadModule
import com.rose.gateway.GatewayPlugin
import com.rose.gateway.config.PluginConfig
import com.rose.gateway.config.access.botToken
Expand All @@ -10,6 +8,8 @@ import com.rose.gateway.minecraft.logging.Logger
import com.rose.gateway.shared.concurrency.PluginCoroutineScope
import dev.kord.core.Kord
import dev.kord.core.exception.KordInitializationException
import dev.kordex.core.ExtensibleBot
import dev.kordex.core.utils.loadModule
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.async
import org.koin.core.component.KoinComponent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.rose.gateway.discord.bot.checks

import com.kotlindiscord.kord.extensions.checks.channelFor
import com.kotlindiscord.kord.extensions.checks.messageFor
import com.kotlindiscord.kord.extensions.checks.types.Check
import com.rose.gateway.discord.bot.DiscordBotController
import dev.kord.core.Kord
import dev.kordex.core.checks.channelFor
import dev.kordex.core.checks.messageFor
import dev.kordex.core.checks.types.Check
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.rose.gateway.discord.bot.client

import com.kotlindiscord.kord.extensions.utils.permissionsForMember
import com.rose.gateway.discord.bot.DiscordBotController
import dev.kord.common.entity.Permissions
import dev.kord.core.entity.channel.GuildChannel
import dev.kordex.core.utils.permissionsForMember
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.rose.gateway.discord.bot.extensions

import com.kotlindiscord.kord.extensions.extensions.Extension
import dev.kordex.core.extensions.Extension
import org.koin.core.component.KoinComponent

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.rose.gateway.discord.bot.extensions.about

import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.ephemeralSlashCommand
import com.rose.gateway.config.PluginConfig
import com.rose.gateway.config.access.aboutExtensionEnabled
import com.rose.gateway.config.access.secondaryColor
import com.rose.gateway.discord.bot.extensions.ExtensionToggle
import com.rose.gateway.minecraft.logging.Logger
import dev.kord.common.Color
import dev.kord.rest.builder.message.embed
import dev.kordex.core.extensions.Extension
import dev.kordex.core.extensions.ephemeralSlashCommand
import org.bukkit.Bukkit
import org.koin.core.component.inject

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.rose.gateway.discord.bot.extensions.chat

import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.event
import com.rose.gateway.config.PluginConfig
import com.rose.gateway.config.access.chatExtensionEnabled
import com.rose.gateway.discord.bot.checks.MessageCheck
import com.rose.gateway.discord.bot.extensions.ExtensionToggle
import com.rose.gateway.discord.bot.extensions.chat.processing.DiscordMessageProcessor
import com.rose.gateway.discord.bot.message.DiscordMessageSender
import com.rose.gateway.minecraft.server.Console
import dev.kordex.core.extensions.Extension
import dev.kordex.core.extensions.event
import org.koin.core.component.inject

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.rose.gateway.discord.bot.extensions.chat

import com.kotlindiscord.kord.extensions.events.KordExEvent
import com.rose.gateway.discord.bot.DiscordBot
import com.rose.gateway.discord.bot.DiscordBotController
import dev.kord.rest.builder.message.create.MessageCreateBuilder
import dev.kordex.core.events.KordExEvent
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.rose.gateway.discord.bot.extensions.chat.processing

import com.kotlindiscord.kord.extensions.utils.getTopRole
import com.rose.gateway.config.PluginConfig
import com.rose.gateway.config.access.secondaryColor
import com.rose.gateway.minecraft.component.atMember
Expand All @@ -17,6 +16,7 @@ import com.rose.gateway.shared.parsing.TextProcessor
import dev.kord.core.entity.Member
import dev.kord.core.entity.Message
import dev.kord.core.event.message.MessageCreateEvent
import dev.kordex.core.utils.getTopRole
import kotlinx.coroutines.flow.toList
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.JoinConfiguration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.rose.gateway.discord.bot.extensions.ip

import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.ephemeralSlashCommand
import com.rose.gateway.config.PluginConfig
import com.rose.gateway.config.access.displayIp
import com.rose.gateway.config.access.ipExtensionEnabled
Expand All @@ -10,6 +8,8 @@ import com.rose.gateway.discord.bot.extensions.ExtensionToggle
import com.rose.gateway.minecraft.logging.Logger
import dev.kord.common.Color
import dev.kord.rest.builder.message.embed
import dev.kordex.core.extensions.Extension
import dev.kordex.core.extensions.ephemeralSlashCommand
import org.koin.core.component.inject

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.rose.gateway.discord.bot.extensions.list

import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.ephemeralSlashCommand
import com.rose.gateway.config.PluginConfig
import com.rose.gateway.config.access.listExtensionEnabled
import com.rose.gateway.config.access.maxPlayersPerListPage
Expand All @@ -14,6 +12,8 @@ import com.rose.gateway.minecraft.server.ServerInfo
import com.rose.gateway.shared.text.plurality
import dev.kord.common.Color
import dev.kord.rest.builder.message.embed
import dev.kordex.core.extensions.Extension
import dev.kordex.core.extensions.ephemeralSlashCommand
import org.koin.core.component.inject

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.rose.gateway.discord.bot.extensions.tps

import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.ephemeralSlashCommand
import com.rose.gateway.config.PluginConfig
import com.rose.gateway.config.access.secondaryColor
import com.rose.gateway.config.access.tpsExtensionEnabled
import com.rose.gateway.discord.bot.extensions.ExtensionToggle
import com.rose.gateway.minecraft.server.ServerInfo
import dev.kord.common.Color
import dev.kord.rest.builder.message.embed
import dev.kordex.core.extensions.Extension
import dev.kordex.core.extensions.ephemeralSlashCommand
import org.koin.core.component.inject
import kotlin.math.roundToInt

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.rose.gateway.discord.bot.extensions.whitelist

import com.kotlindiscord.kord.extensions.commands.Arguments
import com.kotlindiscord.kord.extensions.commands.converters.impl.string
import dev.kordex.core.commands.Arguments
import dev.kordex.core.commands.converters.impl.string

/**
* Arguments for whitelist-related Discord commands
Expand Down
Loading

0 comments on commit fdef7aa

Please sign in to comment.