From 49afa9f2a65d9240feff8ad3e26ccb86d4f3de73 Mon Sep 17 00:00:00 2001 From: Project_IO Date: Thu, 19 Sep 2024 09:49:45 +0900 Subject: [PATCH] feat: avatar command image size --- build.gradle.kts | 86 +++++++------------ px32-bot-core/build.gradle.kts | 46 ++++++++++ .../main/kotlin/net/projecttl/p/x32/Px32.kt | 4 +- .../net/projecttl/p/x32/command/Avatar.kt | 2 +- .../net/projecttl/p/x32/command/Ping.kt | 0 .../net/projecttl/p/x32/config/Config.kt | 0 .../projecttl/p/x32/config/DefaultConfig.kt | 0 .../p/x32/handler/CommandExecutor.kt | 0 .../projecttl/p/x32/handler/CommandHandler.kt | 0 .../net/projecttl/p/x32/handler/Ready.kt | 0 .../net/projecttl/p/x32/kernel/CoreKernel.kt | 0 .../kotlin/net/projecttl/p/x32/util/Color.kt | 0 .../src}/main/resources/default.properties | 0 .../src}/main/resources/log4j2.xml | 0 settings.gradle.kts | 1 + 15 files changed, 83 insertions(+), 56 deletions(-) create mode 100644 px32-bot-core/build.gradle.kts rename {src => px32-bot-core/src}/main/kotlin/net/projecttl/p/x32/Px32.kt (89%) rename {src => px32-bot-core/src}/main/kotlin/net/projecttl/p/x32/command/Avatar.kt (92%) rename {src => px32-bot-core/src}/main/kotlin/net/projecttl/p/x32/command/Ping.kt (100%) rename {src => px32-bot-core/src}/main/kotlin/net/projecttl/p/x32/config/Config.kt (100%) rename {src => px32-bot-core/src}/main/kotlin/net/projecttl/p/x32/config/DefaultConfig.kt (100%) rename {src => px32-bot-core/src}/main/kotlin/net/projecttl/p/x32/handler/CommandExecutor.kt (100%) rename {src => px32-bot-core/src}/main/kotlin/net/projecttl/p/x32/handler/CommandHandler.kt (100%) rename {src => px32-bot-core/src}/main/kotlin/net/projecttl/p/x32/handler/Ready.kt (100%) rename {src => px32-bot-core/src}/main/kotlin/net/projecttl/p/x32/kernel/CoreKernel.kt (100%) rename {src => px32-bot-core/src}/main/kotlin/net/projecttl/p/x32/util/Color.kt (100%) rename {src => px32-bot-core/src}/main/resources/default.properties (100%) rename {src => px32-bot-core/src}/main/resources/log4j2.xml (100%) diff --git a/build.gradle.kts b/build.gradle.kts index c8496ff..9600a43 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,9 +1,5 @@ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - plugins { kotlin("jvm") version "2.0.20" - id("com.gradleup.shadow") version "8.3.0" } group = property("group")!! @@ -13,59 +9,41 @@ val ktor_version: String by project val log4j_version: String by project val exposed_version: String by project -java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(21)) - } +allprojects { + apply(plugin = "org.jetbrains.kotlin.jvm") - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 -} - -repositories { - mavenCentral() -} - -dependencies { - implementation(kotlin("stdlib")) - implementation(kotlin("reflect")) - implementation("net.dv8tion:JDA:5.1.0") - implementation("io.ktor:ktor-client-cio:$ktor_version") - implementation("io.ktor:ktor-client-core:$ktor_version") - implementation("org.apache.logging.log4j:log4j-api:$log4j_version") - implementation("org.apache.logging.log4j:log4j-core:$log4j_version") - implementation("org.jetbrains.exposed:exposed-core:$exposed_version") - implementation("org.jetbrains.exposed:exposed-jdbc:$exposed_version") - implementation("org.apache.logging.log4j:log4j-slf4j2-impl:$log4j_version") - implementation("io.ktor:ktor-client-okhttp-jvm:2.3.12") - testImplementation(platform("org.junit:junit-bom:5.10.0")) - testImplementation("org.junit.jupiter:junit-jupiter") -} - -tasks { - withType { - compilerOptions { - jvmTarget.set(JvmTarget.JVM_21) + java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(21)) } + + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } - processResources { - filesMatching("*.properties") { - expand(project.properties) - } - } - - shadowJar { - archiveBaseName.set(project.name) - archiveClassifier.set("") - archiveVersion.set("") - - manifest { - attributes["Main-Class"] = "net.projecttl.p.x32.Px32Kt" - } - } - - test { - useJUnitPlatform() + repositories { + mavenCentral() } } + +subprojects { + dependencies { + implementation(kotlin("stdlib")) + implementation(kotlin("reflect")) + implementation("net.dv8tion:JDA:5.1.0") + implementation("io.ktor:ktor-client-cio:$ktor_version") + implementation("io.ktor:ktor-client-core:$ktor_version") + implementation("org.apache.logging.log4j:log4j-api:$log4j_version") + implementation("org.apache.logging.log4j:log4j-core:$log4j_version") + implementation("org.jetbrains.exposed:exposed-core:$exposed_version") + implementation("org.jetbrains.exposed:exposed-jdbc:$exposed_version") + implementation("org.apache.logging.log4j:log4j-slf4j2-impl:$log4j_version") + implementation("io.ktor:ktor-client-okhttp-jvm:2.3.12") + testImplementation(platform("org.junit:junit-bom:5.10.0")) + testImplementation("org.junit.jupiter:junit-jupiter") + } +} + +tasks.test { + useJUnitPlatform() +} diff --git a/px32-bot-core/build.gradle.kts b/px32-bot-core/build.gradle.kts new file mode 100644 index 0000000..e880c5e --- /dev/null +++ b/px32-bot-core/build.gradle.kts @@ -0,0 +1,46 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + id("com.gradleup.shadow") version "8.3.0" +} + +group = "net.projecttl" +version = "0.1.0-SNAPSHOT" + +repositories { + mavenCentral() +} + +dependencies { + testImplementation(platform("org.junit:junit-bom:5.10.0")) + testImplementation("org.junit.jupiter:junit-jupiter") +} + +tasks { + withType { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_21) + } + } + + processResources { + filesMatching("*.properties") { + expand(project.properties) + } + } + + shadowJar { + archiveBaseName.set(project.name) + archiveClassifier.set("") + archiveVersion.set("") + + manifest { + attributes["Main-Class"] = "net.projecttl.p.x32.Px32Kt" + } + } + + test { + useJUnitPlatform() + } +} \ No newline at end of file diff --git a/src/main/kotlin/net/projecttl/p/x32/Px32.kt b/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/Px32.kt similarity index 89% rename from src/main/kotlin/net/projecttl/p/x32/Px32.kt rename to px32-bot-core/src/main/kotlin/net/projecttl/p/x32/Px32.kt index d3a699f..007bdf8 100644 --- a/src/main/kotlin/net/projecttl/p/x32/Px32.kt +++ b/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/Px32.kt @@ -1,5 +1,6 @@ package net.projecttl.p.x32 +import net.dv8tion.jda.api.JDA import net.projecttl.p.x32.command.Avatar import net.projecttl.p.x32.command.Ping import net.projecttl.p.x32.config.DefaultConfig @@ -8,6 +9,7 @@ import net.projecttl.p.x32.kernel.CoreKernel import org.slf4j.Logger import org.slf4j.LoggerFactory +lateinit var jda: JDA val logger: Logger = LoggerFactory.getLogger(Px32::class.java) fun main() { @@ -19,7 +21,7 @@ fun main() { handler.addCommand(Avatar) handler.addCommand(Ping) - kernel.build() + jda = kernel.build() } class Px32 diff --git a/src/main/kotlin/net/projecttl/p/x32/command/Avatar.kt b/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/command/Avatar.kt similarity index 92% rename from src/main/kotlin/net/projecttl/p/x32/command/Avatar.kt rename to px32-bot-core/src/main/kotlin/net/projecttl/p/x32/command/Avatar.kt index 621438a..3bf335d 100644 --- a/src/main/kotlin/net/projecttl/p/x32/command/Avatar.kt +++ b/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/command/Avatar.kt @@ -13,7 +13,7 @@ object Avatar : UserContext { override suspend fun execute(ev: UserContextInteractionEvent) { val embed = EmbedBuilder() embed.setTitle(":frame_photo: ${ev.name} Avatar") - embed.setImage(ev.target.effectiveAvatarUrl) + embed.setImage("${ev.target.effectiveAvatarUrl}?size=512") embed.colour() ev.replyEmbeds(embed.build()).queue() diff --git a/src/main/kotlin/net/projecttl/p/x32/command/Ping.kt b/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/command/Ping.kt similarity index 100% rename from src/main/kotlin/net/projecttl/p/x32/command/Ping.kt rename to px32-bot-core/src/main/kotlin/net/projecttl/p/x32/command/Ping.kt diff --git a/src/main/kotlin/net/projecttl/p/x32/config/Config.kt b/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/config/Config.kt similarity index 100% rename from src/main/kotlin/net/projecttl/p/x32/config/Config.kt rename to px32-bot-core/src/main/kotlin/net/projecttl/p/x32/config/Config.kt diff --git a/src/main/kotlin/net/projecttl/p/x32/config/DefaultConfig.kt b/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/config/DefaultConfig.kt similarity index 100% rename from src/main/kotlin/net/projecttl/p/x32/config/DefaultConfig.kt rename to px32-bot-core/src/main/kotlin/net/projecttl/p/x32/config/DefaultConfig.kt diff --git a/src/main/kotlin/net/projecttl/p/x32/handler/CommandExecutor.kt b/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/handler/CommandExecutor.kt similarity index 100% rename from src/main/kotlin/net/projecttl/p/x32/handler/CommandExecutor.kt rename to px32-bot-core/src/main/kotlin/net/projecttl/p/x32/handler/CommandExecutor.kt diff --git a/src/main/kotlin/net/projecttl/p/x32/handler/CommandHandler.kt b/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/handler/CommandHandler.kt similarity index 100% rename from src/main/kotlin/net/projecttl/p/x32/handler/CommandHandler.kt rename to px32-bot-core/src/main/kotlin/net/projecttl/p/x32/handler/CommandHandler.kt diff --git a/src/main/kotlin/net/projecttl/p/x32/handler/Ready.kt b/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/handler/Ready.kt similarity index 100% rename from src/main/kotlin/net/projecttl/p/x32/handler/Ready.kt rename to px32-bot-core/src/main/kotlin/net/projecttl/p/x32/handler/Ready.kt diff --git a/src/main/kotlin/net/projecttl/p/x32/kernel/CoreKernel.kt b/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/kernel/CoreKernel.kt similarity index 100% rename from src/main/kotlin/net/projecttl/p/x32/kernel/CoreKernel.kt rename to px32-bot-core/src/main/kotlin/net/projecttl/p/x32/kernel/CoreKernel.kt diff --git a/src/main/kotlin/net/projecttl/p/x32/util/Color.kt b/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/util/Color.kt similarity index 100% rename from src/main/kotlin/net/projecttl/p/x32/util/Color.kt rename to px32-bot-core/src/main/kotlin/net/projecttl/p/x32/util/Color.kt diff --git a/src/main/resources/default.properties b/px32-bot-core/src/main/resources/default.properties similarity index 100% rename from src/main/resources/default.properties rename to px32-bot-core/src/main/resources/default.properties diff --git a/src/main/resources/log4j2.xml b/px32-bot-core/src/main/resources/log4j2.xml similarity index 100% rename from src/main/resources/log4j2.xml rename to px32-bot-core/src/main/resources/log4j2.xml diff --git a/settings.gradle.kts b/settings.gradle.kts index 7d276bd..cd76ddb 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1 +1,2 @@ rootProject.name = "px32-bot" +include("px32-bot-core")