Skip to content

Commit

Permalink
Merge pull request #11 from ddivad195/feat/dkt-upgrade
Browse files Browse the repository at this point in the history
feat: discordkt 1.23.0-SNAPSHOT update
  • Loading branch information
ddivad195 authored Aug 17, 2021
2 parents edbedea + a6e81ee commit ede901e
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 9 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Empty file modified gradlew
100644 → 100755
Empty file.
8 changes: 7 additions & 1 deletion src/main/kotlin/me/ddivad/keeper/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -34,6 +36,10 @@ suspend fun main() {
allowMentionPrefix = true
theme = Color(0x00BFFF)
entitySupplyStrategy = EntitySupplyStrategy.cacheWithCachingRestFallback
intents = Intents(
Intent.GuildMessageReactions,
Intent.DirectMessagesReactions
)
permissions(Permissions.STAFF)
}

Expand Down Expand Up @@ -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" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
11 changes: 10 additions & 1 deletion src/main/kotlin/me/ddivad/keeper/embeds/Embeds.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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()})")
Expand Down

0 comments on commit ede901e

Please sign in to comment.