diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..ae00691 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,25 @@ +name: Build + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Cache local Maven repository + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: maven-${{ hashFiles('build.gradle') }} + restore-keys: maven- + - name: Build + run: ./gradlew build \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..8a0d93d --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,32 @@ +name: Docker + +on: + push: + branches: [ master ] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - + name: Checkout code + uses: actions/checkout@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} + + - + name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + pull: true + push: true + tags: ddivad195/keeper:latest \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 9024afd..3220e67 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -35,5 +35,5 @@ tasks { object Versions { const val BOT = "1.2.0" - const val DISCORDKT = "0.22.0-SNAPSHOT" + const val DISCORDKT = "0.23.0-SNAPSHOT" } \ No newline at end of file diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/src/main/kotlin/me/ddivad/keeper/Main.kt b/src/main/kotlin/me/ddivad/keeper/Main.kt index 8069009..8a1a474 100644 --- a/src/main/kotlin/me/ddivad/keeper/Main.kt +++ b/src/main/kotlin/me/ddivad/keeper/Main.kt @@ -4,6 +4,8 @@ import dev.kord.common.annotation.KordPreview import dev.kord.common.entity.Snowflake import dev.kord.common.kColor import dev.kord.core.supplier.EntitySupplyStrategy +import dev.kord.gateway.Intent +import dev.kord.gateway.Intents import dev.kord.gateway.PrivilegedIntent import me.ddivad.keeper.dataclasses.Configuration import me.ddivad.keeper.dataclasses.Permissions @@ -34,6 +36,10 @@ suspend fun main() { allowMentionPrefix = true theme = Color(0x00BFFF) entitySupplyStrategy = EntitySupplyStrategy.cacheWithCachingRestFallback + intents = Intents( + Intent.GuildMessageReactions, + Intent.DirectMessagesReactions + ) permissions(Permissions.STAFF) } @@ -63,7 +69,7 @@ suspend fun main() { "Reaction: ${guildConfiguration.bookmarkReaction}\n" + "```") addField("Bot Info", "```" + - "Version: 1.4.1\n" + + "Version: 1.5.0\n" + "DiscordKt: ${it.discord.versions.library}\n" + "Kord: ${it.discord.versions.kord}\n" + "Kotlin: ${KotlinVersion.CURRENT}\n" + diff --git a/src/main/kotlin/me/ddivad/keeper/commands/GeneralCommands.kt b/src/main/kotlin/me/ddivad/keeper/commands/GeneralCommands.kt index 1842bbd..60e2be1 100644 --- a/src/main/kotlin/me/ddivad/keeper/commands/GeneralCommands.kt +++ b/src/main/kotlin/me/ddivad/keeper/commands/GeneralCommands.kt @@ -2,7 +2,7 @@ package me.ddivad.keeper.commands import me.ddivad.keeper.dataclasses.Permissions import me.jakejmattson.discordkt.api.arguments.MessageArg -import me.jakejmattson.discordkt.api.dsl.commands +import me.jakejmattson.discordkt.api.commands.commands @Suppress("unused") fun generalCommands() = commands("General") { diff --git a/src/main/kotlin/me/ddivad/keeper/commands/GuildConfigurationCommands.kt b/src/main/kotlin/me/ddivad/keeper/commands/GuildConfigurationCommands.kt index 4b974bb..654dd15 100644 --- a/src/main/kotlin/me/ddivad/keeper/commands/GuildConfigurationCommands.kt +++ b/src/main/kotlin/me/ddivad/keeper/commands/GuildConfigurationCommands.kt @@ -4,7 +4,7 @@ import me.ddivad.keeper.conversations.ConfigurationConversation import me.ddivad.keeper.dataclasses.Configuration import me.ddivad.keeper.dataclasses.Permissions import me.jakejmattson.discordkt.api.arguments.* -import me.jakejmattson.discordkt.api.dsl.commands +import me.jakejmattson.discordkt.api.commands.commands @Suppress("unused") fun guildConfigurationCommands(configuration: Configuration) = commands("Configuration", Permissions.STAFF) { diff --git a/src/main/kotlin/me/ddivad/keeper/commands/OperationCommands.kt b/src/main/kotlin/me/ddivad/keeper/commands/OperationCommands.kt index 896d55e..117f46f 100644 --- a/src/main/kotlin/me/ddivad/keeper/commands/OperationCommands.kt +++ b/src/main/kotlin/me/ddivad/keeper/commands/OperationCommands.kt @@ -4,7 +4,7 @@ import me.ddivad.keeper.dataclasses.Configuration import me.ddivad.keeper.dataclasses.Permissions import me.ddivad.keeper.services.StatisticsService import me.ddivad.keeper.embeds.buildStatsEmbed -import me.jakejmattson.discordkt.api.dsl.commands +import me.jakejmattson.discordkt.api.commands.commands @Suppress("unused") fun operationCommands(configuration: Configuration, statsService: StatisticsService) = commands("Operation", Permissions.STAFF) { diff --git a/src/main/kotlin/me/ddivad/keeper/conversations/ConfigurationConversation.kt b/src/main/kotlin/me/ddivad/keeper/conversations/ConfigurationConversation.kt index 87675af..711ed13 100644 --- a/src/main/kotlin/me/ddivad/keeper/conversations/ConfigurationConversation.kt +++ b/src/main/kotlin/me/ddivad/keeper/conversations/ConfigurationConversation.kt @@ -9,9 +9,9 @@ import me.jakejmattson.discordkt.api.conversations.conversation class ConfigurationConversation(private val configuration: Configuration) { fun createConfigurationConversation(guild: Guild) = conversation { - val prefix = promptMessage(EveryArg, "Bot prefix:") - val role = promptMessage(RoleArg, "Admin role:") - val reaction = promptMessage(UnicodeEmojiArg, "Save message reaction:") + val prefix = prompt(EveryArg, "Bot prefix:") + val role = prompt(RoleArg, "Admin role:") + val reaction = prompt(UnicodeEmojiArg, "Save message reaction:") configuration.setup(guild, prefix, role, reaction.unicode) } diff --git a/src/main/kotlin/me/ddivad/keeper/embeds/Embeds.kt b/src/main/kotlin/me/ddivad/keeper/embeds/Embeds.kt index 32f1608..09a34b7 100644 --- a/src/main/kotlin/me/ddivad/keeper/embeds/Embeds.kt +++ b/src/main/kotlin/me/ddivad/keeper/embeds/Embeds.kt @@ -1,8 +1,10 @@ package me.ddivad.keeper.embeds +import dev.kord.common.entity.ChannelType import dev.kord.common.kColor import dev.kord.core.entity.Guild import dev.kord.core.entity.Message +import dev.kord.core.entity.channel.thread.ThreadChannel import dev.kord.rest.Image import dev.kord.rest.builder.message.EmbedBuilder import kotlinx.datetime.toJavaInstant @@ -14,12 +16,19 @@ import me.jakejmattson.discordkt.api.extensions.jumpLink import java.awt.Color suspend fun EmbedBuilder.buildSavedMessageEmbed(message: Message, guild: Guild) { + val channel = message.getChannel() + val isThread = channel.type in setOf(ChannelType.PublicGuildThread, ChannelType.PrivateThread) + color = Color(0x00BFFF).kColor author { name = message.author?.tag icon = message.author?.avatar?.url } - description = "**Saved from **${message.channel.mention}\n\n${message.content}" + description = + "**Saved from **" + + "${channel.mention} ${if(isThread) "(${(channel as? ThreadChannel)?.parent?.mention})" else ""}" + + "\n\n${message.content}" + if (message.attachments.isNotEmpty()) image = message.attachments.first().url addField("", "[View Original](${message.jumpLink()})")